【问题标题】:Unable to install packages with pip无法使用 pip 安装软件包
【发布时间】:2019-04-21 14:34:53
【问题描述】:

我的构建机器没有互联网连接。所以我在nexus中创建了名为“proxy_repo”的代理存储库,它指向https://pypi.org/。并在构建机器中创建了 ~/.pip/pip.config。

https://pypi.org/被允许通过nexus从构建机器访问。

pip.conf 内容如下

[global]
trusted-host=MyPrivate-nexusrepo.com
index = https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/pypi
index-url = https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/simple

当我执行任何 pip 命令时,说“pip -v install django”,我总是遇到错误。有人可以帮忙吗?

    Collecting django
  1 location(s) to search for versions of django:
  * https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/simple/django/
  Getting page https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/simple/django/
  Looking up "https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/simple/django/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): MyPrivate-nexusrepo.com
  "GET /content/repositories/proxy_repo/simple/django/ HTTP/1.1" 404 None
  Could not fetch URL https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/simple/django/: 404 Client Error: Not Found for url: https://MyPrivate-nexusrepo.com/content/repositories/proxy_repo/simple/django/ - skipping
  Could not find a version that satisfies the requirement django (from versions: )
Cleaning up...
No matching distribution found for django

【问题讨论】:

    标签: python pip nexus


    【解决方案1】:

    经常让在受限环境中运行的人绊倒的一件事是,必须允许通过公司防火墙访问这两个服务器:

    https://pypi.org/

    https://files.pythonhosted.org/

    原因是对第一个 URL 的请求通常会重定向到第二个请求的内容。

    【讨论】:

      【解决方案2】:

      我以前遇到过这个问题,通过设置我的日期和时间解决了我的问题。如果计算机的日期和时间不是当前的,它会阻止从 Python.org 获取数据

      【讨论】:

      • 机器的日期和时间设置正确。但我仍然遇到错误。
      猜你喜欢
      • 2019-03-09
      • 2017-07-27
      • 2020-07-02
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      • 2015-09-28
      • 2018-08-04
      相关资源
      最近更新 更多