在macOS Catalina 10.15.5中安装时,psycopg2给出了错误

时间:2020-07-13 14:03:48

标签: python django postgresql macos psycopg2

我正在尝试在django项目中安装psycopg2。这给了我这个错误。我已经安装(psycopg2二进制文件,枕头和其他软件包,它们工作正常)。我刚刚重新安装了macOS和Xcode。我正在使用python 3.8.3&Django 3.0.5和Homebrew 2.4.5和我的PostgreSQL 12.3

Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:

 
 command:
 /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c
 'import sys, setuptools, tokenize; sys.argv[0] =
 '"'"'/private/var/folders/hj/q_49d8351l11gj135qs6c01r0000gn/T/pip-install-zr_qlm_k/psycopg2/setup.py'"'"';
 __file__='"'"'/private/var/folders/hj/q_49d8351l11gj135qs6c01r0000gn/T/pip-install-zr_qlm_k/psycopg2/setup.py'"'"';f=getattr(tokenize,
 '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
 '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
 install --record
 /private/var/folders/hj/q_49d8351l11gj135qs6c01r0000gn/T/pip-record-rc16k7t9/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/psycopg2
 
ld: library not found for -lssl
     clang: error: linker command failed with exit code 1 (use -v to see invocation)
     error: command 'gcc' failed with exit status 1
     ---------------------------------------- ERROR: Command errored out with exit status 1:
 /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c
 'import sys, setuptools, tokenize; sys.argv[0] =
 '"'"'/private/var/folders/hj/q_49d8351l11gj135qs6c01r0000gn/T/pip-install-zr_qlm_k/psycopg2/setup.py'"'"';
 __file__='"'"'/private/var/folders/hj/q_49d8351l11gj135qs6c01r0000gn/T/pip-install-zr_qlm_k/psycopg2/setup.py'"'"';f=getattr(tokenize,
 '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
 '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
 install --record
 /private/var/folders/hj/q_49d8351l11gj135qs6c01r0000gn/T/pip-record-rc16k7t9/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/psycopg2
 Check the logs for full command output.

1 个答案:

答案 0 :(得分:3)

请使用psycopg2-binary,它将完美安装。

pip install psycopg2-binary