python setup.py Egg_info 未成功运行:尝试安装 psycopg2 时

问题描述 投票:0回答:1

我在尝试运行 psycopg2 时遇到了这个问题,任何有解决方案的人都会有所帮助,谢谢!

Collecting psycopg2==2.8.6 (from -r requirements.txt (line 45))
  Using cached psycopg2-2.8.6.tar.gz (383 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [37 lines of output]
      running egg_info
      creating /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info
      writing /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/dependency_links.txt
      writing top-level names to /tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/top_level.txt
      writing manifest file '/tmp/pip-pip-egg-info-kg2ft5p1/psycopg2.egg-info/SOURCES.txt'
      /home/lungsang/Desktop/Contextus/env/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
 
      
      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      
      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>).
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

当我尝试运行 psycopg2 并升级 setuptools 时出现此错误,但仍然没有解决。

django ubuntu psycopg2
1个回答
0
投票

你安装了吗

python-dev
? 如果您已经安装了,请尝试安装
libpq-dev

sudo apt-get install libpq-dev python-dev

如果没有解决,请尝试

psycopg2-binary

pip3 install psycopg2-binary
© www.soinside.com 2019 - 2024. All rights reserved.