首页 > 解决方案 > 无法在 Windows 上安装 psycopg2 2.8.6

问题描述

我无法在我的 Windows 上安装 psycopg2 2.8.6 或 psycopg2-binary。安装时出现以下错误。

PS C:\Users\UserName\Desktop\PythonUnitTestFW> pip install psycopg2-binary 收集 psycopg2-binary 使用缓存的 psycopg2-binary-2.8.6.tar.gz (384 kB) 错误:命令错误退出状态 1:命令: 'c:\python39\python.exe' -c '导入系统,setuptools,tokenize;sys.argv[0] = '"'"'C:\Users\UserName\AppData\Local\Temp\pip-install-e12d1gsx\psycopg2-binary\setup.py'"'"'; file ='"'"'C:\Users\UserName\AppData\Local\Temp\pip-install-e12d1gsx\psycopg2-binary\setup.py'"'"';f=getattr(tokenize, '"'"' open'"'"', open)( file );code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'", '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\UserName\AppData\Local\Temp\pip-pip-egg-info-bs6x9b8l' cwd: C:\ Users\UserName\AppData\Local\Temp\pip-install-e12d1gsx\psycopg2-binary
完整输出(23 行):运行 egg_info 创建 C:\Users\UserName\AppData\Local\Temp\pip-pip-egg-info- bs6x9b8l\psycopg2_binary.egg-info 写入 C:\Users\UserName\AppData\Local\Temp\pip-pip-egg-info-bs6x9b8l\psycopg2_binary.egg-info\PKG-INFO 将 dependency_links 写入 C:\Users\UserName\ AppData\Local\Temp\pip-pip-egg-info-bs6x9b8l\psycopg2_binary.egg-info\dependency_links.txt
将顶级名称写入 C:\Users\UserName\AppData\Local\Temp\pip-pip-egg- info-bs6x9b8l\psycopg2_binary.egg-info\top_level.txt 写入清单文件'C:\Users\UserName\AppData\Local\Temp\pip-pip-egg-info-bs6x9b8l\psycopg2_binary.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 检查日志以获取完整的命令输出。

标签: pythonpython-3.xpsycopg2

解决方案


推荐阅读