微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我们如何在Linux中解决Psycopg2的路径错误?

如何解决我们如何在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。它讨论了相同的问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。