pip使用国内镜像源

默认情况下pip使用的是国外的镜像源,在下载的时候速度非常慢。
可以直接在pip命令中使用-i参数来指定镜像地址

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

这种只对当前安装对命令有用,如果需要全局修改,则需要修改配置文件
在Linux环境中,配置文件在 ~/.pip/pip.conf(如果不存在创建该目录和文件)

mkdir ~/.pip
vim ~/.pip/pip.conf

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

查看镜像地址

pip config list


global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'
install.trusted-host='https://pypi.tuna.tsinghua.edu.cn'

windows下当前对用户目录下(C:\Users\xx\pip,xx 表示当前使用对用户,比如张三)创建一个 pip.ini在pip.ini文件中输入以下内容:

index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

其他国内镜像源
● 中国科学技术大学 : https://pypi.mirrors.ustc.edu.cn/simple
● 豆瓣:http://pypi.douban.com/simple/
● 阿里云:http://mirrors.aliyun.com/pypi/simple/

posted @   梁永旺  阅读(210)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示