pip 说 setuptools 版本 40.8.0 不满足 setuptools>=40.8.0 的要求

Ray*_*oIL 11 python pip

我对这个问题感到非常困惑,找不到任何匹配的问题。

如果我运行pip3 show setuptoolspip2 list,两者都表示setuptools 40.8.0已安装,但是当我尝试从本地源代码目录在本地安装模块时,我收到错误消息No matching distribution found for setuptools>=40.8.0

由于访问和防火墙限制,我必须将该模块安装到我的主目录中并使用系统上已安装的内容。

这适用于该模块的先前版本,但现在失败了。

sna*_*erb 7

我在尝试使用气隙机器上下载的依赖项从源代码构建 psycopg 时遇到了这个问题。

\n

我最初是这样做的:

\n
$ python3.11 -m venv tmp-venv\n$ . tmp-venv/bin/activate\n$ pip list\nPackage    Version\n---------- -------\npip        22.3.1\nsetuptools 65.5.0\n$ mkdir deps\n$ pip download --destination-dir=deps wheel tomli==2.0.1 backports.zoneinfo==0.2.1 typing_extensions==4.7.1 psycopg==3.1.9 psycopg-c==3.1.9\n$ pip install --no-index --find-links=deps wheel tomli\n
Run Code Online (Sandbox Code Playgroud)\n

然后我执行了

\n
$ pip install --no-index --find-links=deps psycopg[c]\n
Run Code Online (Sandbox Code Playgroud)\n

出错了

\n
  \xc3\x97 pip subprocess to install build dependencies did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [3 lines of output]\n      Looking in links: deps\n      ERROR: Could not find a version that satisfies the requirement setuptools>=49.2.0 (from versions: none)\n      ERROR: No matching distribution found for setuptools>=49.2.0\n      [end of output]\n
Run Code Online (Sandbox Code Playgroud)\n

从这个 GitHub 问题中收集到的解决方案是添加--no-build-isolation标志,以便pip找到setuptools安装。

\n
pip install --no-index --find-links=deps --no-build-isolation psycopg[c]\n
Run Code Online (Sandbox Code Playgroud)\n

构建隔离是 PEP518 的一项功能,其中构建过程不会在本地环境中查找构建时依赖项(例如 setuptools)。该--no-build-isolation标志禁用此功能,以便使用本地 setuptools 安装进行构建。

\n