python - 无法使用 pip 安装软件包
问题描述
我的构建机器没有互联网连接。所以我在 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
解决方案
经常让在受限环境中运行的人绊倒的一件事是,必须允许通过公司防火墙访问这两个服务器:
https://files.pythonhosted.org/
这样做的原因是对第一个 URL 的请求通常会重定向到第二个请求的内容。
推荐阅读
- reactjs - 反应 - 更新
- c# - 尝试从数据库 GridView 特定用户 (OleDbCommand) 进行更新
- python - 如何在 matplotlib 中交替散点图的颜色?
- pytorch - Pytorch 重建损失
- algorithm - 两个栈和一个deque,实现它的目的是什么?
- wordpress - 如何将帖子显示为元素但从网址中删除帖子
- vue.js - 如何在 Nuxtjs App 中删除加载百分比微调器
- java - 字符串循环旋转的更好方法
- git - 我可以从某人的本地工作仓库中执行 git checkout 分支吗?
- c++ - 使用时钟()输出持续时间,但输出相乘