GKLBB

当你经历了暴风雨,你也就成为了暴风雨

导航

常见问题解决 --- python必备技能 换源

源是什么

源是编程开发或则是操作系统要使用的第三方依赖软件应用市场,源又从何而来,其实源来自其他的源的克隆,或者是源提供者自己收集,编译,又或者作者的上传

为什么要换源

这些源往往都在国外,国内以为你懂的原因无法直接访问或者特别慢

怎么换

Windows下python永久换源方式有两种:

修改配置文件pip.ini

 C:\Users\lhsmd(用户名)\AppData\Roaming\pip\pip.ini或者类似文件名,打开

[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple
trusted-host = pypi.douban.com

 

其他源自己添加

# 腾讯
http://mirrors.tencentyun.com/pypi/simple
# 阿里
https://mirrors.aliyun.com/pypi/simple
# 豆瓣
https://pypi.douban.com/simple
# 中科大
https://pypi.mirrors.ustc.edu.cn/simple/
# 清华
https://pypi.tuna.tsinghua.edu.cn/simple

 

命令行

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

 

 临时换源

pip install 软件名  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 

linux下

永久换    在终端执行下面命令,向/$HOME/.pip/目录创建pip.conf文件添加源

mkdir -p /$HOME/.pip/ && echo -e "[global]\nindex-url = https://pypi.mirrors.ustc.edu.cn/simple/\n" > /$HOME/.pip/pip.conf && pip3 install pycryptodome

永久换源 命令行

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

临时换源

pip install 软件名  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 

posted on 2023-05-14 12:39  GKLBB  阅读(758)  评论(0)    收藏  举报