python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > python更换国内镜像源

python更换国内镜像源三种实用方法

作者:破壳的小企鹅

这篇文章主要给大家介绍了关于python更换国内镜像源三种实用方法的相关资料,更换Python镜像源可以帮助解决使用pip安装包时速度过慢或无法连接的问题,需要的朋友可以参考下

方法1:(永久更改)

在python的命令提示符中运行以下语句,该条语句将pip的下载源永久更改为某个镜像站,这里以清华大学开源镜像站为例:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

方法2:(永久更改)

windows环境下,在用户目录中创建一个文件夹,该文件夹的命名为pip;在该pip文件夹中新建一个文件pip.ini,pip.ini的内容如下:(完整路径:C:\Users\用户名\pip\pip.ini)

[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple 
[install]  
trusted-host=pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true  
timeout = 6000

方法3:(临时性使用)

在安装库的时候,临时需要用到某个镜像,这里以清华大学镜像为例下载pandas库:

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

备注:pip下载源常用的国内镜像如下:

豆瓣:http://pypi.douban.com/simple/
阿里云:http://mirrors.aliyun.com/pypi/simple/
华为云:https://repo.huaweicloud.com/repository/pypi/simple
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
中科大:https://pypi.mirrors.ustc.edu.cn/simple/

总结 

到此这篇关于python更换国内镜像源三种实用方法的文章就介绍到这了,更多相关python更换国内镜像源内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文