pip下载镜像在requirements.txt或venv中

huangapple go评论72阅读模式
英文:

pip download mirror in requirements.txt or venv

问题

有没有办法在 requirements.txt 文件中修复 PyPi 下载镜像?或者在其他自动选择的地方修复?我在中国,通常会使用备用镜像,因为主要镜像可能会很慢,例如:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

今天这导致我很困惑,因为我的 Python 代码和 requirements.txt 在不同的机器上产生了意外和不同的结果。

英文:

Is there a way to fix the PyPi download mirror in a requirements.txt file? or somewhere else that gets picked up automatically? I'm based in China, and it's often convenient to use an alternative mirror as the main one can be slow e.g.

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Today this caused me a lot of confusion, as my Python code & requirements.txt produced unexpected and different results on different machines.

答案1

得分: 3

你可以在你的requirements.txt文件中添加以下内容:

--index-url https://pypi.tuna.tsinghua.edu.cn/simple

请查看文档

英文:

You should be able to just include

--index-url https://pypi.tuna.tsinghua.edu.cn/simple

in your requirements.txt file. See the documentation

huangapple
  • 本文由 发表于 2023年4月20日 09:40:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76059948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定