I am trying to get postgresql up and running on my computer to use with python3. From what I understand, I have to download postgresql and then psycopg2. I used the command
brew install postgresql
which worked without any error. I then proceeded to do
pip3 install psycopg2
but got the error
ERROR: Could not find a version that satisfies the requirement pyscopg2 (from versions: none)
ERROR: No matching distribution found for pyscopg2
I know that psycopg2-binary exists, but I would rather not install it unless I have to.
EDIT: Turns out as wu.guan.feng.yue pointed out, I had a typo (fixed now). Unfortunately, I just got another error.
Collecting psycopg2
Using cached psycopg2-2.9.1.tar.gz (379 kB)
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-install-w901ehls/psycopg2_8dfb1124ccd54b17b1211b191de99482/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-install-w901ehls/psycopg2_8dfb1124ccd54b17b1211b191de99482/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-record-x11loqj9/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/psycopg2
cwd: /private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-install-w901ehls/psycopg2_8dfb1124ccd54b17b1211b191de99482/
Complete output (34 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.9
creating build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/_json.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/extras.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/errorcodes.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/tz.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/_range.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/_ipaddress.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/extensions.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/errors.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/sql.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
copying lib/pool.py -> build/lib.macosx-10.9-x86_64-3.9/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.macosx-10.9-x86_64-3.9
creating build/temp.macosx-10.9-x86_64-3.9/psycopg
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=130003 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I. -I/usr/local/include -I/usr/local/include/postgresql/server -I/usr/local/Cellar/icu4c/69.1/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -c psycopg/adapter_asis.c -o build/temp.macosx-10.9-x86_64-3.9/psycopg/adapter_asis.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-install-w901ehls/psycopg2_8dfb1124ccd54b17b1211b191de99482/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-install-w901ehls/psycopg2_8dfb1124ccd54b17b1211b191de99482/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/6bvbfsfn6fqdl6wzjp52ykj80000gn/T/pip-record-x11loqj9/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/psycopg2 Check the logs for full command output.