更改pip镜像源的多种方法

2023-05-16

目前可用的pip国内镜像源有下面这些:

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣 http://pypi.douban.com/simple

Python官方 https://pypi.python.org/simple/

v2ex http://pypi.v2ex.com/simple/

中国科学院 http://pypi.mirrors.opencas.cn/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
 
中国科学技术大学 [http://pypi.mirrors.ustc.edu.cn/simple/]
 
华中理工大学:[http://pypi.hustunique.com/]
 
山东理工大学:[http://pypi.sdutlinux.org/]

Windows下具体方法如下:

1.临时使用:

在使用pip的时候加参数-i,如下:

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

注:numpy为包名

2.手动切换镜像源

# 全局设置镜像源地址
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3.永久使用

①windows下,在user目录中创建一个pip文件夹,如C:\Users\xx\pip,在pip文件夹中新建文件pip.ini,内容如下:

[global]
timeout=40
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=
        http://mirrors.aliyun.com/pypi/simple/
        http://pypi.douban.com/simple
        http://pypi.mirrors.ustc.edu.cn/simple/

[install]
trusted-host=
        pypi.tuna.tsinghua.edu.cn
        mirrors.aliyun.com
        pypi.douban.com
        pypi.mirrors.ustc.edu.cn

为了防止一个镜像失效的问题,这里设置了多个镜像,你也可以天际其他的有效镜像

②打开设置→关于→高级系统设置→环境变量→系统变量→path→新建

新建内容:

%HOME%\pip\pip.ini

4.查看更改后的镜像源

pip config list

或者

pip3 config list
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

更改pip镜像源的多种方法 的相关文章

随机推荐