python - 我们如何解决 Linux 中 psycopg2 的路径错误?
问题描述
我正在使用 conda 包,在尝试安装 psycopg2 时出现此错误。我想要这个用于 postgis,我在 ubuntu 上运行。
ERROR: Command errored out with exit status 1:
command: /home/srijan/anaconda3/envs/django/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-s5yimrpg/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-s5yimrpg/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 /tmp/pip-pip-egg-info-cop18avg
cwd: /tmp/pip-install-s5yimrpg/psycopg2/
Complete output (14 lines):
running egg_info
creating /tmp/pip-pip-egg-info-cop18avg/psycopg2.egg-info
writing /tmp/pip-pip-egg-info-cop18avg/psycopg2.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-cop18avg/psycopg2.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-pip-egg-info-cop18avg/psycopg2.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-cop18avg/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
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'.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方案
安装python-dev
(可能是python3-dev
,根据您当前的 python 版本安装),libpq-dev
应该可以解决您的问题。
另请查看此 stackoverflow 问题pg_config executable not found。它谈到了同样的问题。
推荐阅读
- php - 我只是不小心用 cPanel 中的另一个文件替换了我的整个 php 代码-有什么办法可以取回该代码吗?
- ios - 无法将 UIPickerView 中的选定值保存到数组
- javascript - 当页面重新调整为较小的宽度时,如何防止页面内容重新调整大小
- android - 根据android kotlin中所需的输出格式显示日期不起作用
- awk - sed 命令删除与模式 (sed) 匹配的行块(上方和下方) - 使用 Python 解决
- css - 用于提取文本的 GTM CSS 选择器
- javascript - 当我敲击键盘 Enter 键以访问网页时,我需要展开和折叠纯 CSS 手风琴
- powerbi - 上个月值的 DAX 公式
- c - 我们如何检查给定的输入是否是有效的系统命令,如 c 程序中的“ls”或“cd”?
- java - 如何在一行中找到最大的数字序列?