首页 > 解决方案 > 我们如何解决 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.

标签: pythondjangocondapostgis

解决方案


安装python-dev(可能是python3-dev,根据您当前的 python 版本安装),libpq-dev应该可以解决您的问题。

另请查看此 stackoverflow 问题pg_config executable not found。它谈到了同样的问题。


推荐阅读