解决方法,设置超时时间

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/python
 
import os
 
package = 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" % package
os.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 源的更多相关文章

  1. 为你的pip更换一个国内的镜像源

    为你的pip更换一个国内的镜像源 是否常常为pypi官网被无故和谐掉导致pip不能下载python的各个包而痛心疾首? 是否常常在深夜里看着pip install 下载包的速度慢如乌龟而长吁短叹? 是 ...

  2. pip命令使用国内pypi镜像源加速在线安装

    参考:http://www.cnblogs.com/yudar/p/4444097.html 用easy_install和pip来安装第三方库很方便 它们的原理其实就是从Python的官方源pypi. ...

  3. pip安装报错处理+PyPi源切换教程

    一.pip安装出错类型 1.1 pip版本过旧导致不能安装 报错提示: You are using pip version 9.0.3, however version 10.0.1 is avail ...

  4. pip操作以及window和虚拟机中为pip更换一个国内的镜像源的方法

    前言 在学习PyQt5的过程中,参考王硕和孙洋洋的PyQt5快速开发与实战中,看到的关于Python开发技巧与实战,觉得挺好的 所以将其摘抄了下来方便阅读.之后还有一个关于更换pip镜像源的方法,方便 ...

  5. pip 安装包 使用国内镜像源

    1.pipy国内镜像目前有: 阿里云  http://mirrors.aliyun.com/pypi/simple/  中国科技大学  https://pypi.mirrors.ustc.edu.cn ...

  6. python 安装模块之pip install +模块名的换源写法

    1.采用国内源,加速下载模块的速度2.常用pip源(上一篇博客介绍过):– 豆瓣:https://pypi.douban.com/simple– 阿里:https://mirrors.aliyun.c ...

  7. 修改apt,pip,npm为国内镜像源

    apt 原文件备份 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 编辑源列表文件 sudo vim /etc/apt/sources. ...

  8. socket.timeout: The read operation timed out 更改pip源至国内镜像,显著提升下载速度

    出现socket.timeout: The read operation timed out  错误的时候,可能是pip源不稳定,改改试试看!  经常在使用Python的时候需要安装各种模块,而pip ...

  9. pip安装模块使用国内镜像源加速安装

    今天在安装Python模块matplotlib的时候,一直安装不成功,老是提示“socket.timeout: The read operation timed out”或者“Read timed o ...

随机推荐

  1. 怎样用命令行开启或关闭Windows服务

    怎样用命令行开启或关闭Windows服务 本篇博客主要包含一个内容: 怎样用命令行开启或关闭Windows服务 闲话少叙,直奔主题. 1.在桌面右击新建一个文本文档,然后打开. 2.找到需要开启或关闭 ...

  2. Ant Design Pro的dva-loading

    loading为dva的插件,全局可用,它里面维护了一些布尔值,用于控制loading动画效果的显示与隐藏,通过@connect()来注入使用 官网介绍如下: https://dvajs.com/ 在 ...

  3. 数据库的未来:ORM+LINQ+RX

    数据库的未来:ORM+LINQ+RX 数据        操作         异步 ORM       LINQ        RX

  4. Android-SpinKit 进度条 (ProgressBar)

    项目地址: https://github.com/ybq/Android-SpinKit 类别: 进度条 (ProgressBar) 打分: ★★★★★ 更新: 2016-03-28 11:17 大小 ...

  5. 【转】VMware 14 Pro安装mac os 10.12

    一.准备工作 [1]资源下载 VMware Workstation Pro 14 已安装或自行安装 Unlocker (链接: https://pan.baidu.com/s/1dG5jkuH 密码: ...

  6. PHP设计模式_工厂模式

    个人理解工厂类相当于平时用的基类,只需要把类new一次然后付给一个变量,以后直接引入基类调用变量使用类里的方法即可 了解 工厂模式,工厂方法或者类生成对象,而不是在代码中直接new. 使用工厂模式,可 ...

  7. Python:Day06 元组、字典、字符串

    tuple(元组) 元组被称为只读列表,即数据可以被查询,但不能被修改,所以列表的切片操作同样适用于元组. 元组写在( )里,元素之间用逗号隔开. tul1 = ( ) #空元组 tul2 = (20 ...

  8. openvon安装

    一.安装环境 1.阿里云centos7 2.关闭防火墙,selinux 临时关闭:setenforce 0 永久关闭:vim /etc/selinux/config 3.修改yum源 1)备份原有的y ...

  9. C语言初学者关于数组指针的深度讨论

    一.什么是数组指针? 即是数组的指针.首先它是一个指针,指向数组,指针本身占4个字节. 二.数组指针的使用 int a[3][5]; int (*p)[5]; p=&a; 第二行定义了一个数组 ...

  10. Java模拟登录带验证码的教务系统(原理详解)

    一:原理 客户端访问服务器,服务器通过Session对象记录会话,服务器可以指定一个唯一的session ID作为cookie来代表每个客户端,用来识别这个客户端接下来的请求. 我们通过Chrome浏 ...