首页 > 解决方案 > 具有嵌套依赖项的 Pip index-url 问题

问题描述

我目前在内部服务器上安装了一个 pip 镜像(这是一个离线网络)。访问它的 url 是http://pypi.python.org/simple。我在 ~/.pip/pip.conf 创建了一个配置文件,内容如下:

[global]
index-url = http://pypi.python.org/simple
trusted-host = pypi.python.org

我可以成功安装没有嵌套依赖项的包,例如通过执行pip3 install requests. 我成功安装了请求、idna、chardet、certifi 和 urllib3 的输出。但是,当我需要从具有嵌套依赖项的 pip 安装某些东西时,例如 via pip3 install driller,我会得到以下输出:

Collecting driller
  Downloading driller-1.0.tar.gz
Collecting angr (from driller)
  Downloading angr-8.19.2.4.tar.gz (758kB)
  100% |                          | 768kB 75.7MB/s
  Complete output from command python setup.py egg_info:
  Download error on https://pypi.python.org/simple/pyvex/: [Errno 111] Connection refused -- Some packages may not be found!
  ...

对我来说很奇怪,错误是由于尝试访问https://pypi.python.org/simple而不是我通过http://pypi.python.org上的 index-url 指定的本地镜像而发生的。此外,如果我执行pip3 install pyvex它安装就好了。当存在嵌套依赖项时,我是否错过了如何通过 pip install 命令传播我的 index-url/受信任的主机?

标签: pythonpipofflinemirror

解决方案


我有完全相同的问题,并在StackOverflow上的这个线程中得到了答案。

这是解决方案

在您的系统上找到 Python 目录并将以下两行添加到distutils.cfg文件夹中distutils。如果配置文件尚不存在,请创建它。

[easy_install]
index_url = blablabla

推荐阅读