python国内镜像源网址与使用方法
时间: 2025-02-09 09:09:42 浏览: 83
### Python国内镜像源及其配置
#### 常见的Python国内镜像源地址
多个知名机构提供了Python包的镜像服务,这些镜像可以加速依赖项下载速度:
- 清华大学:`https://pypi.tuna.tsinghua.edu.cn/simple`[^2]
- 阿里云:`http://mirrors.aliyun.com/pypi/simple/`
- 中国科学技术大学:`https://pypi.mirrors.ustc.edu.cn/simple/`
- 华中理工大学:`http://pypi.hustunique.com/`
- 山东理工大学:`http://pypi.sdutlinux.org/`
- 豆瓣:`http://pypi.douban.com/simple/`[^1]
#### Windows系统的pip镜像源临时设置方法
对于Windows操作系统,在命令行工具中可以通过追加 `-i` 参数来指定特定的索引URL用于单次安装操作。例如要通过清华大学的镜像安装NumPy库,则执行如下命令:
```bash
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
```
此方式不会改变全局默认的索引服务器设定。
#### 修改pip配置文件实现永久变更
为了使新的镜像成为默认选项而无需每次都手动输入完整的安装指令,可以在用户的home目录下创建或编辑`.pip/pip.conf`(Linux/MacOS) 或者 `%APPDATA%\pip\pip.ini`(Windows),并加入以下内容以指向所需的镜像站点为例:
```ini
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
```
这样以后每次运行 `pip install` 的时候都会自动使用所选中的镜像站作为数据源了。
阅读全文
相关推荐


















