python pip镜像源设置
时间: 2024-12-25 15:15:09 浏览: 51
在Python中,`pip`是包管理器,用于安装、升级和卸载软件包。如果你需要更改默认的镜像源,主要是为了提高下载速度或者访问受限地区的库,可以设置国内的镜像源。以下是常见的步骤:
1. **阿里云PyPI源**:
- 使用命令行运行:`pip config set global index-url https://mirrors.aliyun.com/pypi/simple/`
- 或者编辑 `~/.pip/pip.conf` 文件(创建如果不存在),添加这一行:`[global] index-url = https://mirrors.aliyun.com/pypi/simple/`
2. **清华大学开源中国源**:
- 命令行:`pip config set global index-url http://pypi.douban.com/simple/`
- 或者文件编辑:`[global] index-url = http://pypi.douban.com/simple/`
3. **中科大源**:
- 对于Python 3.x:`pip config set global index-url https://pypi.mirrors.ustc.edu.cn/simple/`
- 对于Python 2.x:`pip install --extra-index-url https://pypi.mirrors.ustc.edu.cn/simple/`
4. **更换为国际源** (如官方):
- 如果你想恢复到官方源,删除上述配置即可,直接使用`pip install package_name`。
记得每次更改后,需要运行`pip cache clear`清除缓存,以便新的镜像源生效。
阅读全文
相关推荐


















