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 ...
随机推荐
- LeetCode算法题-Valid Anagram(Java实现)
这是悦乐书的第198次更新,第205篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第61题(顺位题号是242).给定两个字符串s和t,写一个函数来确定t是否是s的anag ...
- 记录参加QCon2017北京站的心得
如有侵权,请告知作者删除.scottzg@126.com 很荣幸参加QCon全球软件开发大会,这里特别感谢我们部门的总经理,也是<互联网广告算法和系统实践>此书的作者王勇睿.因为他我才有这 ...
- 1. 路过面了个试就拿到2个offer。是运气吗?
路过随便面个试就拿到2个offer.是运气吗? #复习很重要#看看面试问的问题,再瞧瞧师兄的学习态度,你就明白 机会为何总与你擦肩而过了.[玫瑰] 以下是我和师兄的聊天记录,你会几个?
- Spring 的application.properties项目配置与注解
一.项目结构介绍 如上图所示,Spring Boot的基础结构共三个文件: src/main/java 程序开发以及主程序入口 src/main/resources 配置文件 src/test/ja ...
- docker学习笔记(三)-通过network理解docker,在同一网桥里搭建docker容器
创建test1 test2 两个network namespace 两个network namespace没有被启动 启动了但是有没有与network关联 创建两个veth,用于关联两个network ...
- php面试题整理(五)
表单也得改
- springboot统一异常处理类及注解参数为数组的写法
统一异常处理类 package com.wdcloud.categoryserver.common.exception; import com.wdcloud.categoryserver.commo ...
- Python装饰器 [1]
装饰器本身是个函数 import time def log(func): def wrapper(*args, **kwargs): start = time.time() result = func ...
- P1553 数字反转(升级版)(模拟)
花了2个小时,写的..mmp只想说,还是我太菜了. #include<iostream> #include<cstring> using namespace std; ]; i ...
- linux内存源码分析 - 内存压缩(同步关系)
本文为原创,转载请注明:http://www.cnblogs.com/tolimit/ 概述 最近在看内存回收,内存回收在进行同步的一些情况非常复杂,然后就想,不会内存压缩的页面迁移过程中的同步关系也 ...