python 国内镜像加速
原因
经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具
但是由于国外官方默认pip访问速度慢,经常被墙,导致无法安装,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的烦恼
# 查看已经安装软件列表
$ pip freeze
# 查看当前配置
$ python -m site
USER_BASE和USER_SITE其实就是用户自定义的启用Python脚本和依赖安装包的基础路径
镜像列表
http://mirrors.aliyun.com/pypi/simple/ //阿里
https://pypi.tuna.tsinghua.edu.cn/simple/ //清华
http://pypi.douban.com/ //豆瓣
http://pypi.hustunique.com/ //华中理工大学
http://pypi.sdutlinux.org/ //山东理工大学
http://pypi.mirrors.ustc.edu.cn/ //中国科学技术大学
国内使用得比较多并且速度比较快的是阿里的pip源或者清华大学,清华大学的是官网pypi的镜像
临时使用
pip的时候加参数 -i
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent
常驻使用
Linux or macOS
修改 ~/.pip/pip.conf (没有就自己创建), 增加或者修改 index-url 至源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true
- 豆瓣源使用
mkdir -p ~/.pip
echo -e '[global]\ntrusted-host = pypi.douban.com\nindex-url = http://pypi.douban.com/simple' > ~/.pip/pip.conf
windows
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip
新建文件 pip.ini 内容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true
timeout = 120
或者使用豆瓣源
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
disable-pip-version-check = true
timeout = 120
- index-url 源,可以换成其他的源
- trusted-host 添加源为可信主机,要不然可能报错
- disable-pip-version-check 设置为true取消pip版本检查,排除每次都报最新的pip
- timeout 超时设置
mkdir -p ~/.pip
echo -e '[global]\ntrusted-host = pypi.douban.com\nindex-url = http://pypi.douban.com/simple' > ~/.pip/pip.conf
windows
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip
新建文件 pip.ini 内容
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
disable-pip-version-check = true
timeout = 120
或者
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true
timeout = 120
pip conf 参数说明
[install]安装参数install-option=--prefix=pip install的安装路径[global]表示为全局配置- index-url 源,可以换成其他的源
- trusted-host 添加源为可信主机,要不然可能报错
- disable-pip-version-check 设置为true取消pip版本检查,排除每次都报最新的pip
- timeout 超时设置
python 国内镜像加速的更多相关文章
- python 使用pip安装使用国内镜像加速下载安装包的方法
清华大学提供开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ pypi 镜像每 5 分钟同步一次. pip install 包的名字 == 版 ...
- pip安装库时报错,使用国内镜像加速
pip install requests或pip --trusted-host pypi.python.org install requests报错: 原因:网上解释为网速太慢,或被防火墙 解决方法: ...
- docker学习(2) mac中docker-machine使用vmware fusion以及配置国内镜像加速
一.前言 先回顾下上一节创建docker-machine的过程,默认情况下docker toolbox中的docker-machine使用virtual box创建虚拟机,KI首次启动时创建虚拟机的过 ...
- 安装使用yarn,使用国内镜像加速npm和yarn
安装yarn https://yarnpkg.com/lang/zh-hans/docs/install/ 使用国内镜像加速npm和yarn 1. npm config set registry=ht ...
- Python pip 下载速度慢? Windows 设置 国内源,用 阿里云 国内镜像 加速
pip 提供了对 Python 包的查找.下载.安装.卸载的功能,是非常方便的 Python 包管理工具.但是,令人苦恼的是 pip 在国内的下载速度非常慢,速度常常只有每秒几十 K,甚至才几 K,小 ...
- 使用国内镜像加速下载Android SDK
本文转自:http://blog.kuoruan.com/24.html.感谢原作者. 什么是Android SDK SDK:(software development kit)软件开发工具包.被软件 ...
- python国内镜像源
让python pip使用国内镜像 国内源: 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pyp ...
- Python 国内镜像源
让 python pip 使用国内镜像源 国内镜像源: 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.co ...
- python 国内镜像
pipy国内镜像目前有: http://pypi.douban.com/ 豆瓣 http://pypi.hustunique.com/ 华中理工大学 http://pypi.sdutlinux.o ...
随机推荐
- Codeforces 510C (拓扑排序)
原题:http://codeforces.com/problemset/problem/510/C C. Fox And Names time limit per test:2 seconds mem ...
- IntelliJ IDEA更新maven依赖包
问题: IntelliJ IDEA自动载入Maven依赖的功能很好用,但有时候会碰到问题,导致pom文件修改却没有触发自动重新载入的动作,此时需要手动强制更新依赖. 方法: 方法一: ①.右键单击项目 ...
- 信息安全-威胁防御系统-Fortinet:Fortinet
ylbtech-信息安全-威胁防御系统-Fortinet:Fortinet Fortinet 是多层威胁防御系统的创新者和先锋.该系统能够为业务通信提供最佳安全.优秀性能和低总体占用成本. Forti ...
- python 将图片存入mongodb,读取图片,gridfs模块
导入图片引入模块,其中gridfs模块不需要单独安装,引入了pymongo即可直接引入from pymongo import MongoClientfrom gridfs import *import ...
- Kali开启SSH服务
1. 一.配置SSH参数 修改sshd_config文件,命令为: vi /etc/ssh/sshd_config 将#PasswordAuthentication no的注释去掉,并且将NO修 ...
- Embedding和Word2Vec实战
在之前的文章中谈到了文本向量化的一些基本原理和概念,本文将介绍Word2Vec的代码实现 https://www.cnblogs.com/dogecheng/p/11470196.html#Word2 ...
- MSF——信息收集(四)
MSF系列: MSF——基本使用和Exploit模块(一) MSF——Payload模块(二) MSF——Meterpreter(三) MSF——信息收集(四) 发现和端口扫描 Nmap扫描 db_n ...
- Scrapy框架: 通用爬虫之XMLFeedSpider
步骤01: 创建项目 scrapy startproject xmlfeedspider 步骤02: 使用XMLFeedSpider模版创建爬虫 scrapy genspider -t xmlfeed ...
- 如何多个router 进行合并?
有时间可能有多个人开发,如果在共用router, 势必会造成合并冲突,可以分开多个router.js ,然后进行合并 // router0.jsconst studyRouter = [ { path ...
- HDFS文件的基本操作
HDFS文件的基本操作: package wjn; import java.io.BufferedInputStream; import java.io.BufferedReader; import ...