热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

linuxpip3使用清华源_pip使用国内镜像源的介绍

默认情况下pip使用的是国外的镜像,在下载的时候速度非常慢,本文我们介绍使用国内清华大学的源.国内镜像源地址为:https:pypi.tu

默认情况下 pip 使用的是国外的镜像,在下载的时候速度非常慢,本文我们介绍使用国内清华大学的源.

9ee6ae6af78af5e0011cc5659d959369.png

国内镜像源

地址为:

https://pypi.tuna.tsinghua.edu.cn/simple

我们可以直接在 pip 命令中使用 -i 参数来指定镜像地址,例如:

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

以上命令使用清华镜像源安装 numpy 包。

这种只对当前安装对命令有用,如果需要全局修改,则需要修改配置文件。

Linux/Mac os 环境中,配置文件位置在 ~/.pip/pip.conf(如果不存在创建该目录和文件):

mkdir ~/.pip

打开配置文件 ~/.pip/pip.conf,修改如下:

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

查看 镜像地址:

$ pip3 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文件中输入以下内容:

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

其他国内镜像源

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

2. 豆瓣:http://pypi.douban.com/simple/原文来自:https://www.runoob.com/w3cnote/pip-cn-mirror.html

本文地址:https://www.linuxprobe.com/introduction-of-pip.html

Linux命令大全:https://www.linuxcool.com/



推荐阅读
author-avatar
白小蛮
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有