python - 在 Windows 中安装 psycopg2 时出错
问题描述
嗨,我正在开发一个 Django 项目,在 Windows 上安装 psycopg2 时遇到错误
pip install psycopg2
我也试过
pip install psycopg2-binary
但仍然出现错误
ERROR: Command errored out with exit status 1:
command: 'c:\users\theuser\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\theuser\\AppData\\Local\\Temp\\pip-install-zh83zqbg\\psycopg2\\setup.py'"'"'; __file__='"'"'C:\\Users\\theuser\\AppData\\Local\\Temp\\pip-install-zh83zqbg\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j'
cwd: C:\Users\theuser\AppData\Local\Temp\pip-install-zh83zqbg\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info
writing C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\theuser\AppData\Local\Temp\pip-pip-egg-info-upmu4r_j\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>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方案
关键是这样的:
Error: pg_config executable not found.
要么您没有安装开发工具(pg_config
属于它们),要么安装可执行文件的目录不在您的PATH
环境变量中。
推荐阅读
- python-3.x - 调用装饰函数两次只返回装饰器而不返回函数
- mysql - 如何在没有日历表的情况下向 mysql 查询添加天间隔
- php - $result 总是返回 1 ,而不是数据库中想要的 ID
- testing - 在 Azure DevOps 中使用 Pipelines 以更好的方式显示测试结果
- angular - 如何删除空格 - Angular 8 数据绑定
- c# - 在 C# 上的 documentNode 中获取特定节点
- r - 如何根据 R 中重复标称值的总和计算新值
- r - R函数将向量转换为列
- python-3.x - 添加数据点期间散点图中的静态颜色图
- haskell - 实现二叉树集