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 ...
随机推荐
- [福大软工] Z班 团队作业——随堂小测(同学录) 作业成绩
团队作业--随堂小测(同学录) 作业链接 http://www.cnblogs.com/easteast/p/7763645.html 作业情况 本次作业从原先预计的3小时,有些组打了鸡血连续肝了4. ...
- 精度 Precision
柏拉图认为,尽管世间万物是不完美的,但存在一种永恒不变的形式,这个形式是完美的,而生命的意义就是让这个世界尽可能的接近这个完美的形式. 怎么理解这句话,和我们今天讲的精度有什么关系.我们先举一个例子, ...
- ccf 再买菜 搜索 dfs
//递推关系式:(b[n-1]+b[n]+b[n+1])/3=a[n] //所以b[n+1]=3*a[n]-b[n-1]-b[n],或b[n+1]=3*a[n]-b[n-1]-b[n]+1,或b[n+ ...
- dp 动态规划 蘑菇
蘑菇真的贵,友情价更高 Description 由于提莫为巡逻准备的蘑菇太多了,多余的蘑菇路上种不下,于是他精心挑选了一些蘑菇拜访他的好朋友小炮 提莫的蘑菇一共有n个,对于编号为i的蘑菇魔力值是a ...
- ElasticSearch(三):Java操作ElasticSearch索引之CRUD
package com.gxy.ESChap01; import java.net.InetAddress; import java.util.HashMap; import java.util.Ma ...
- centos7下kubernetes(7.kubernetesScale Up/Down)
伸缩(Scale up/down)是指在线增加或减少pod副本数量 通过yml文件创建两个nginx的pod 先查看一下nginx的yml文件: 通过kubectl apply -f创建 通过kube ...
- UVA1374-Power Calculus(迭代加深搜索)
Problem UVA1374-Power Calculus Accept:107 Submit:584 Time Limit: 3000 mSec Problem Description In ...
- ubuntu 在 Windows 下的安装
1. ubuntu 下载官网:https://www.ubuntu.com/index_kylin
- pg安装入门
1.下载源码安装包 [root@test2019030517 ~]# wget https://ftp.postgresql.org/pub/source/v10.5/postgresql-10.5. ...
- 洛谷题解 P1031 【均分纸牌】
这道题很简单 原理是从左到右一个一个排,把差值m加起来加到后面一堆牌里 具体ac代码如下: #include<cstdio> #include<iostream> #inclu ...