pip国内镜像源配置
个人博客地址:pip国内镜像源配置 | 一张假钞的真实世界
以清华大学镜像源为例:Simple Index
单次使用镜像源
在pip安装命令后添加-i
参数指定镜像源:
pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple
永久配置镜像源
使用命令配置
简单的方式是使用命令配置。
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
修改pip配置文件
创建或修改pip配置文件:
- Linux/MacOS: ~/.pip/pip.conf
- Windows: %APPDATA%\pip\pip.ini 或 %USERPROFILE%\pip\pip.ini
添加以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
常用国内镜像源
- 清华大学:Simple Index
- 阿里云:Simple Index
- 中国科技大学:Verifying - USTC Mirrors
恢复默认源
删除配置文件或运行:
pip config unset global.index-url