pip怎么切换源
- 使用命令行切换源
可以通过以下命令在命令行中切换pip源:
- 清华源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple - 阿里云源:
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/ - 中科大源:
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/ - 豆瓣源:
pip config set global.index-url https://pypi.douban.com/simple/
- 使用配置文件切换源
可以通过修改pip的配置文件来切换源:
- 找到pip的配置文件,一般在
~/.pip/pip.conf或/etc/pip.conf中。 - 在配置文件中添加以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
将index-url替换为你想要使用的源的地址。
- 使用第三方工具切换源
也可以使用第三方工具来切换pip源,例如:
- pipenv:
pipenv install --pypi-mirror https://pypi.tuna.tsinghua.edu.cn/simple - pipx:
pipx install --index-url https://pypi.tuna.tsinghua.edu.cn/simple package_name
以上是一些常用的方法,具体可以根据实际情况选择适合自己的方式。
原文地址: https://www.cveoy.top/t/topic/b5Ij 著作权归作者所有。请勿转载和采集!