欢迎访问我的网站,希望内容对您有用,感兴趣的可以加入免费知识星球。

添加国内镜像源,让pip下载安装飞起来

Python基础 迷途小书童 4年前 (2019-12-08) 4097次浏览 0个评论

软硬件环境

  • ubuntu 18.04 64bit
  • anaconda with python 3.6
  • pip

前言

在使用 pip 安装第三方依赖库时,由于众所周知的国内网络环境,经常是下载到了一半就断开,重复多次也无果。幸运的是,国内有些公司和高校已经做了镜像,使用他们的下载源,速度快的飞起,妈妈再也不用担心 pip 安装了,让大家把更多精力放在 coding 本身吧。

pip_error

更换国内镜像源

这里以阿里云的源为例,其它的类似,文章末尾会贴出一些已测的可用源,如果一个不行就切换到另一个。

Linux/MacOS 系统

mkdir ~/.pip
touch ~/.pip/pip.conf

添加的配置文件内容如下 pip.conf

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

Windows 系统

C:\Users\$登录用户名下创建文件夹pip,然后在pip文件夹下创建文件pip.ini,文件内容和上边的pip.conf一样

其它的镜像源

清华大学

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

[install]
trusted-host=pypi.tuna.tsinghua.edu.cn

中国科技大学

[global]
index-url = https://mirrors.ustc.edu.cn/pypi/web/

[install]
trusted-host=mirrors.ustc.edu.cn

豆瓣

[global]
index-url = http://pypi.douban.com/simple

[install]
trusted-host=pypi.douban.com
喜欢 (0)

您必须 登录 才能发表评论!

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

请关闭 Adblock 等类似浏览器插件,然后刷新页面访问,感谢您的支持!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.