Python pip源使用国内镜像,,常用镜像源豆瓣 ht


常用镜像源

豆瓣 https://pypi.douban.com/simple阿里云 https://mirrors.aliyun.com/pypi/simple清华大学 https://pypi.tuna.tsinghua.edu.cn/simple中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple官方 https://pypi.python.org/simple/

使用说明

临时使用

使用-i选项,将镜像源地址作为参数。
例:在pip中使用清华大学pip源安装youtube-dl

pip install youtube-dl -i https://pypi.tuna.tsinghua.edu.cn/simple

永久使用

编辑pip配置文件,将index-url的值修改为你要使用的镜像的地址。

pip的配置文件一般位于(如果没有,请直接创建):

- Unix 环境: `$HOME/.config/pip/pip.conf`- macOS: `$HOME/Library/Application Support/pip/pip.conf`- Windows: `%APPDATA%\pip\pip.ini`

更多资料:https://pip.pypa.io/en/stable/user_guide/#configuration

pip.conf文件配置示例如下:

[global]index-url = https://mirrors.ustc.edu.cn/pypi/web/simpleformat = columns

常见问题

使用pip时如果出现configparser.MissingSectionHeaderError: File contains no section headers.,说明你的pip.conf忘记加上[global]这一行了。

参考资料:http://mirrors.ustc.edu.cn/help/pypi.html

Python pip源使用国内镜像

评论关闭