pip Read timed out 和 pip 源
解决方法,设置超时时间
pip --default-timeout=100 install -U Pillow
安装时指定源(--index-url)
#例如安装scipy时使用豆瓣的源
pip install --index-url https://pypi.douban.com/simple scipy
PyPI使用国内源
通过几次 pip 的使用,对于默认的 pip 源的速度实在无法忍受,于是便搜集了一些国内的pip源,如下:
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
使用方法很简单,直接 -i 加 url 即可!如下:
|
1
|
# pip install web.py -i http://pypi.douban.com/simple |
如果有如下报错:

请使用命令:
|
1
|
# pip install web.py -i http://pypi.douban.com/simple --trusted-host pypi.douban.com |
如果想配置成默认的源,方法如下:
需要创建或修改配置文件(一般都是创建),
linux的文件在~/.pip/pip.conf,
windows
win10: %appdata%下
Win7: C:\Users\xxx\ 或 %USERPROFILE%下
目录下新建pip文件夹,在pip文件夹下新建pip.ini文件
修改内容为:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
disable-pip-version-check = true
timeout = 120 或: [global]
trusted-host=mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple
disable-pip-version-check = true
timeout = 120
这样在使用pip来安装时,会默认调用该镜像。
临时使用其他源安装软件包的python脚本如下:
|
1
2
3
4
5
6
7
|
#!/usr/bin/pythonimport ospackage = raw_input("Please input the package which you want to install!\n")command = "pip install %s -i http://pypi.mirrors.ustc.edu.cn/simple --trusted-host pypi.mirrors.ustc.edu.cn" % packageos.system(command) |
也可以使用读入文件进行安装。
ok,仅以记录一下,以便于后期查阅!
------日期:2018年11月1日 增加Python配置pip默认源脚本,复制到pip_source.py,执行即可。

#!/usr/bin/python
# coding: utf-8 import platform
import os os_type = platform.system()
if "Linux" == os_type:
fileDirPath = "%s/.pip" % os.path.expanduser('~')
filePath = "%s/pip.conf" % fileDirPath
if not os.path.isdir(fileDirPath):
os.mkdir(fileDirPath)
fo = open(filePath, "w")
fo.write(
"[global]\nindex-url=https://pypi.tuna.tsinghua.edu.cn/simple/\n[install]\ntrusted-host=pypi.tuna.tsinghua.edu.cn\n")
fo.close()
print "Configuration is complete"
elif "Windows" == os_type:
fileDirPath = "%s\\pip" % os.path.expanduser('~')
filePath = "%s\\pip.ini" % fileDirPath
if not os.path.isdir(fileDirPath):
os.mkdir(fileDirPath)
fo = open(filePath, "w")
fo.write(
"[global]\nindex-url=https://pypi.tuna.tsinghua.edu.cn/simple/\n[install]\ntrusted-host=pypi.tuna.tsinghua.edu.cn\n")
fo.close()
print "Configuration is complete"
else:
exit("Your platform is unknow!")

pip Read timed out 和 pip 源的更多相关文章
- 为你的pip更换一个国内的镜像源
为你的pip更换一个国内的镜像源 是否常常为pypi官网被无故和谐掉导致pip不能下载python的各个包而痛心疾首? 是否常常在深夜里看着pip install 下载包的速度慢如乌龟而长吁短叹? 是 ...
- pip命令使用国内pypi镜像源加速在线安装
参考:http://www.cnblogs.com/yudar/p/4444097.html 用easy_install和pip来安装第三方库很方便 它们的原理其实就是从Python的官方源pypi. ...
- pip安装报错处理+PyPi源切换教程
一.pip安装出错类型 1.1 pip版本过旧导致不能安装 报错提示: You are using pip version 9.0.3, however version 10.0.1 is avail ...
- pip操作以及window和虚拟机中为pip更换一个国内的镜像源的方法
前言 在学习PyQt5的过程中,参考王硕和孙洋洋的PyQt5快速开发与实战中,看到的关于Python开发技巧与实战,觉得挺好的 所以将其摘抄了下来方便阅读.之后还有一个关于更换pip镜像源的方法,方便 ...
- pip 安装包 使用国内镜像源
1.pipy国内镜像目前有: 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn ...
- python 安装模块之pip install +模块名的换源写法
1.采用国内源,加速下载模块的速度2.常用pip源(上一篇博客介绍过):– 豆瓣:https://pypi.douban.com/simple– 阿里:https://mirrors.aliyun.c ...
- 修改apt,pip,npm为国内镜像源
apt 原文件备份 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 编辑源列表文件 sudo vim /etc/apt/sources. ...
- socket.timeout: The read operation timed out 更改pip源至国内镜像,显著提升下载速度
出现socket.timeout: The read operation timed out 错误的时候,可能是pip源不稳定,改改试试看! 经常在使用Python的时候需要安装各种模块,而pip ...
- pip安装模块使用国内镜像源加速安装
今天在安装Python模块matplotlib的时候,一直安装不成功,老是提示“socket.timeout: The read operation timed out”或者“Read timed o ...
随机推荐
- SAP LOGON 快捷登陆方式如何保存密码
默认情况下,快捷方式密码是不能输入的. 解决方法:修改注册表: 计算机\HKEY_CURRENT_USER\Software\SAP\SAPShortcut\Security EnablePasswo ...
- Linux 小知识翻译 - 「代理服务器」
这回聊聊「代理服务器」. 在公司里,不通过代理服务器无法连接互联网的,由于代理服务器的原因,有些服务的使用是受到限制的. 有人可能会觉得为什么会存在这种东西?(这里指代理服务器) Proxy本来的意思 ...
- Cesium实现键盘控制镜头效果
w-前进 a-左转 d-右转 s-后退 q-上仰 鼠标左键按住左右移动更换角度 html代码如下: <div id="cesiumContainer" style= ...
- 《Java大学教程》—第17章 Java聚焦类框架
由所有聚焦类构成,在java.util包中,包含三个重要接口:* List列表:元素为单个对象,元素在列表中是有序.可重复* Set集合:元素为单个对象,元素在集合中无序.不可重复* ...
- 分布式消息中间件rocketmq的原理与实践
RocketMQ作为阿里开源的一款高性能.高吞吐量的消息中间件,它是怎样来解决这两个问题的?RocketMQ 有哪些关键特性?其实现原理是怎样的? 关键特性以及其实现原理 一.顺序消息 消息有序指的是 ...
- 【vue】vue +element 搭建项目,$createElement使用
语法: 它有三个参数 第一个:html标签名 第二个:配置的数据对象 第三个:内容 应用1:自定义弹窗 html: <el-button type="text" @click ...
- (三)JavaScript 语法
字符串(String)字面量 可以使用单引号或双引号: "John Doe" 'John Doe' 数组(Array)字面量 定义一个数组: [40, 100, 1, 5, 25, ...
- modbus与rs485的关系_modbus与rs485的区别和联系
http://www.elecfans.com/tongxin/123/20180103610476.html 经常看到RS485和MODBUS写在一起,它们的区别和联系? RS485是一个物理接口, ...
- Spring Security(十六):5.7 Multiple HttpSecurity
We can configure multiple HttpSecurity instances just as we can have multiple <http> blocks. T ...
- 如何让Node.js运行在浏览器端
Node.js又称服务端JavaScript.今天我为了解决一个问题,通过搜索引擎找到了如何将Node.js转成浏览器端可以运行的javascript.尽管这种方式有其局限性,但是还是可以用的. 1. ...