我无法在 Mac 上使用 Python3 安装 Psycopg2.我已经安装了 Python3 和 pip3
我尝试输入以下命令:pip3 install --user psycopg2 psycopg2-binary
I've tried to type this command: pip3 install --user psycopg2 psycopg2-binary
Bash 答案:错误:运行安装
Bash answers: ERROR: running install
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
<http://initd.org/psycopg/docs/install.html>).
error: command 'gcc' failed with exit status 1
----------------------------------------
错误:命令/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/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/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-record-lkzzuu55/install-record.txt --single-version-externally-managed --compile" 失败,错误代码 1 在/private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2
ERROR: Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/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/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-record-lkzzuu55/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qf/kmd2_y0j2p9_10zkd5ctvm880000gn/T/pip-install-i0kg4ysj/psycopg2/
您无法安装 psycopg2,因为您设备中的 gcc 编译器已过时且不兼容安装和运行它,或者它不存在.
You're not being able to install psycopg2 as the gcc compiler in your device is either outdated and not compatible to install and run it, or it does not exist.
如果您只是运行 pip install psycopg2-binary
,那么它可以在您的开发和测试环境中运行,但不建议用于生产环境.
if you just run pip install psycopg2-binary
, then it will work on your development and testing environment, however it is not recommended for production.
要安装 psycopg2,请通过运行 - 确保您的设备中安装了 gcc-
To install psycopg2, make sure that you have gcc installed in your device by running-
gcc --versiongcc where
如果没有安装,请参考这里的指南进行安装-
If it is not installed, then install it by referring to the guide here-
我希望这会有所帮助.:)
I hope this helps. :)