命令“ python setup.py egg_info”在PATH / psycopg2中失败,错误代码为1

Per*_*ira 2 pip psycopg2 virtualenv python-2.7 postgresql-11

我需要将PostgreSQL从9.5版升级到11版。之后,当我从“ requirements.txt”文件重新创建virtualEnv时,在安装psycopg2软件包时开始出现以下错误:

Collecting psycopg2 == 2.6.2 (from -r conf/requirements.txt (line 50))
  Using cached https://files.pythonhosted.org/packages/7b/a8/dc2d50a6f37c157459cd18bab381c8e6134b9381b50fbe969997b2ae7dbc/psycopg2-2.6.2.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: could not determine PostgreSQL version from '11 .1 '
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-0Q7bhV/psycopg2/
Run Code Online (Sandbox Code Playgroud)

Per*_*ira 8

经过一番研究,我运行了以下命令来尝试解决,但是没有用:

sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common
Run Code Online (Sandbox Code Playgroud)

最后,我注意到psycopg2的2.6.2版本仅支持PostgreSQL的9.5版本。对于11,您应该使用最新版本的psycopg2,即版本2.7.7。在您更改了requirements.txt文件之后,正确地重新创建了virtualEnv。

希望对其他人有用。