''' pip安装psycopg2 收集psycopg2 使用缓存的psycopg2-2.8.5.tar.gz(380 kB) 错误:命令错误,退出状态为1: 命令:/ opt / anaconda3 / bin / python -c'导入sys,setuptools,令牌化; sys.argv [0] ='“'”'/private/var/folders/v8/vk9679rj7m7f03_0hztz3rc80000gn/T/pip-install-d7jzvy68/psycopg2/setup.py'“”“; 文件 ='“'”'/ private / var / folders / v8 / vk9679rj7m7f03_0hztz3rc80000gn / T / pip-install-d7jzvy68 / psycopg2 / setup.py'“'”'; f = getattr(tokenize, '“'”'open'“'”',打开)(文件); code = f.read()。replace('“ '“'”'\ n'“'”'); f.close(); exec(compile(code, file ,'“'”'exec'“'”')))'egg_info --egg-base / private / var / folders / v8 / vk9679rj7m7f03_0hztz3rc80000gn / T / pip-pip-egg-info-6sv6r8te CWD:/ private / var / folders / v8 / vk9679rj7m7f03_0hztz3rc80000gn / T / pip-install-d7jzvy68 / psycopg2 / 完整输出(23行): 运行egg_info 创建/private/var/folders/v8/vk9679rj7m7f03_0hztz3rc80000gn/T/pip-pip-egg-info-6sv6r8te/psycopg2.egg-info 编写/private/var/folders/v8/vk9679rj7m7f03_0hztz3rc80000gn/T/pip-pip-egg-info-6sv6r8te/psycopg2.egg-info/PKG-INFO 将dependency_links写入/private/var/folders/v8/vk9679rj7m7f03_0hztz3rc80000gn/T/pip-pip-egg-info-6sv6r8te/psycopg2.egg-info/dependency_links.txt 将顶级名称写入/private/var/folders/v8/vk9679rj7m7f03_0hztz3rc80000gn/T/pip-pip-egg-info-6sv6r8te/psycopg2.egg-info/top_level.txt 写入清单文件'/private/var/folders/v8/vk9679rj7m7f03_0hztz3rc80000gn/T/pip-pip-egg-info-6sv6r8te/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
----------------------------------------
错误:命令错误,退出状态为1:python setup.py egg_info检查日志以获取完整的命令输出。 '''
答案 0 :(得分:3)
您可以安装预编译的二进制文件。有关更多信息,请参阅此Answer。
pip install psycopg2-binary
答案 1 :(得分:0)
请按照说明进行操作: 您可以添加目录,也可以使用以下选项指定完整路径。 另一个解决方案是setup.cfg
要从源代码构建psycopg2,需要pg_config。请添加目录 包含pg_config到$ PATH或使用 选项:
python setup.py build_ext --pg-config /path/to/pg_config build ...
或在'setup.cfg'中使用pg_config选项。
否则,只需使用以下命令: pip install psycopg2-binary->在消息中也建议使用
如果您不想避免从源代码构建psycopg2,请安装PyPI 改为使用“ psycopg2-binary”软件包。