【发布时间】:2021-06-21 14:30:08
【问题描述】:
我下载了一个 github 存储库并运行 python setup.py 文件,它从 linux 终端运行$python setup.py 命令,但我收到以下错误
[setup.py] Running [sudo apt-get -y install libjsoncpp-dev postgresql jq python-psycopg2 python-sqlalchemy socat libpq-dev cmake docker.io bc python-pexpect python-psutil python-lockfile genisoimage inotify-tools build-essential python-pip libprotobuf-c0-dev libodb-pgsql-2.4 libfdt-dev] . . .
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-psycopg2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip
E: Package 'python-psycopg2' has no installation candidate
E: Package 'python-pip' has no installation candidate
E: Unable to locate package libprotobuf-c0-dev
[setup.py] [sudo apt-get -y install libjsoncpp-dev postgresql jq python-psycopg2 python-sqlalchemy socat libpq-dev cmake docker.io bc python-pexpect python-psutil python-lockfile genisoimage inotify-tools build-essential python-pip libprotobuf-c0-dev libodb-pgsql-2.4 libfdt-dev] cmd did not execute properly.
尝试一一修复错误,首先我尝试使用pip install psycopg2安装python-psycopg2,输出为:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: psycopg2 in 'path'
我也尝试运行 python -m pip install psycopg2 但输出没有改变。所以我下载了源代码(来自https://pypi.org/project/psycopg2/#files)并使用了我得到的setup.py:
File "setup.py", line 117
f"Unable to find 'pg_config' file in '{self.pg_config_exe}'")
^
SyntaxError: invalid syntax
如何修复所有错误?是 python 2.7 的问题吗?
【问题讨论】:
-
试试 pip3 install psycopg2
-
@DSteman 绝对有效,但是当我再次运行 python2 setup.py 时,我总是遇到同样的错误
-
你为什么用python2而不是python3?
-
@DSteman 我从github下载的框架是3年前的,好像不支持python3
-
我明白了。如果你试试这个: pip install psycopg2-binary
标签: python python-2.7 setup.py