pip 没有读取 ~/.pip/pip.conf

Posted

技术标签:

【中文标题】pip 没有读取 ~/.pip/pip.conf【英文标题】:pip not reading the ~/.pip/pip.conf 【发布时间】:2021-07-10 15:39:44 【问题描述】:

这与 jfrog 工件有关。 pypi-public 是我们的虚拟仓库,我们的内部 pypi-internal 与 pypi-public 相关联。我可以在 Web UI 上看到包 vapi_common。

下面的命令可以搜索包

pip search vapi_common --index=https://<username>:<apikey>@company.jfrog.io/artifactory/api/pypi/pypi-public/simple

但是,如果我在 ~/.pip/pip.conf 中使用相同的 index-url

[global]
index-url = https://<username>:<apikey>@company.jfrog.io.jfrog.io/artifactory/api/pypi/pypi-public/simple

然后使用下面的命令 pip search vapi_common -vvv -> 失败以下错误。如您所见,它正在尝试访问 pypi.org 并且不遵守 pip.conf 中给出的索引 url

pip search vapi_common -vvv
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "POST /pypi HTTP/1.1" 200 419
ERROR: Exception:
Traceback (most recent call last):
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
    status = self.run(options, args)
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pip/_internal/commands/search.py", line 60, in run
    pypi_hits = self.search(query, options)
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pip/_internal/commands/search.py", line 80, in search
    hits = pypi.search('name': query, 'summary': query, 'or')
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/xmlrpc/client.py", line 1109, in __call__
    return self.__send(self.__name, args)
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/xmlrpc/client.py", line 1450, in __request
    response = self.__transport.request(
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pip/_internal/network/xmlrpc.py", line 45, in request
    return self.parse_response(response.raw)
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/xmlrpc/client.py", line 1341, in parse_response
    return u.close()
  File "/home/varmour/.pyenv/versions/3.8.8/lib/python3.8/xmlrpc/client.py", line 655, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32500: "RuntimeError: PyPI's XMLRPC API is currently disabled due to unmanageable load and will be deprecated in the near future. See https://status.python.org/ for more information.">

【问题讨论】:

【参考方案1】:

请注意您自己使用pip search --index=…。也就是说,您应该在pip.conf 中使用选项index,而不是index-urlindex 用于pip searchindex-url 用于pip download/install

请参阅https://pip.pypa.io/en/stable/reference/pip_search/#options 上的文档

修复配置:

pip config set global.index https://:@company.jfrog.io.jfrog.io/artifactory/api/pypi/pypi-public/simple

也许

pip config set global.index `pip config get global.index-url`

【讨论】:

以上是关于pip 没有读取 ~/.pip/pip.conf的主要内容,如果未能解决你的问题,请参考以下文章

CentOs 永久置换pip镜像源

pip 常用镜像源及永久配置镜像源

pip和apt-get换源

pip源设置并批量下载包

pip源设置并批量下载包

pip源设置并批量下载包