python - 当 pip.conf 在别处指定时,为什么 pip 试图访问 pypi.python.org?

标签 python pip

我的组织使用 artifactory,一个本地包存储库管理器。 Artifactory 提供了一个名为 Remote Repositories 的功能,它为远程存储库提供代理和缓存功能,我们使用它来代理和缓存对 PyPi 的访问(有关更多详细信息,请参阅 PyPi Repositories)。

为了使用这个远程存储库,必须在 pip.conf 中添加一个条目。我已经在需要安装一些机器的盒子上完成了这项工作,但是当我发出 pip 命令(在我的例子中是 sudo -E pip install --ignore-installed pip setuptools wheel )时,pip 似乎忽略了 pip.conf 中的内容,而是试图到达 https://pypi.python.org

这是我刚刚运行的记录:

$ cat /etc/pip.conf  
[global]  
index-url = https://username:password@artifactory.myorg.com/artifactory/api/pypi/pypi-remote/simple  

$ sudo -E pip
install --ignore-installed pip setuptools wheel  
Downloading/unpacking pip  
  Cannot fetch index base URL https://pypi.python.org/simple/   
  Could not find any downloads that satisfy the requirement pip  
Cleaning up...  
No distributions at all found for pip  
Storing debug log for failure in /home/jamiet/.pip/pip.log  

$ cat /home/jamiet/.pip/pip.log   
Downloading/unpacking pip   
   Getting page https://pypi.python.org/simple/pip/
   Could not fetch URL https://pypi.python.org/simple/pip/: connection error: ('Connection aborted.', error(101, 'Network is unreachable'))
  Will skip URL https://pypi.python.org/simple/pip/ when looking for download links for pip  
   Getting page https://pypi.python.org/simple/   Could not
fetch URL https://pypi.python.org/simple/: connection error:
('Connection aborted.', error(101, 'Network is unreachable'))
  Will skip URL https://pypi.python.org/simple/ when looking for download
links for pip
  Cannot fetch index base URL https://pypi.python.org/simple/  
  URLs to search for versions for pip:
* https://pypi.python.org/simple/pip/  
  Getting page https://pypi.python.org/simple/pip/  
  Could not fetch URL https://pypi.python.org/simple/pip/: connection error: ('Connection
aborted.', error(101, 'Network is unreachable'))  
  Will skip URL https://pypi.python.org/simple/pip/ when looking for download link for pip  
  Could not find any downloads that satisfy the requirement pip  
Cleaning up... No distributions at all found for pip  

谁能向我解释为什么当 pip.conf 指示它去不同的地方时 pip 试图达到 https://pypi.python.org/simple/pip/

最佳答案

我们使用的是 2014 年 5 月发布的旧版 pip 1.5.6。当我们在命令行中指定 index-url 时 sudo -E pip install --index-url https://username:password@artifactory.myorg.com/artifactory/api/pypi/pypi-remote/simple --ignore-installed pip setuptools wheel一切都按预期工作,所以我们假设这个旧版本的 pip 不使用 pip.conf ,或者,如果使用,它不会以相同的方式使用它。

一旦该命令(升级 pip)成功完成,在同一脚本中对 pip 的后续调用就不需要 --index-url指定是因为他们按预期使用了 pip.conf。

关于python - 当 pip.conf 在别处指定时,为什么 pip 试图访问 pypi.python.org?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54305326/

相关文章:

python - 无法安装 Keras

python - 导入错误: cannot import name 'relu6'

python - Pip 安装失败 : SSL required

Python没有 "see"一个包

python - 如何使用 scipy.optimize.least_squares 计算标准偏差误差

python - 无法在套接字程序中获取字符串

python - 将 .strip() 用于二维列表

python - 'package data' 文件在哪里?

python - Python 中的虚拟对象

python - 'UpdateView' 对象没有属性 'object'