pip 安装包时 Read timed out 你们都是怎么解决的?

2016-12-13 12:59:55 +08:00
 ansheng
bogon:~ ansheng$ pip install --upgrade pip
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    0% |                                | 4.1kB 17.7MB/s eta 0:00:01Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 282, in run
    requirement_set.prepare_files(finder)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 491, in _prepare_file
    session=self.session)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/download.py", line 825, in unpack_url
    session,
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/download.py", line 673, in unpack_http_url
    from_path, content_type = _download_http_url(link, session, temp_dir)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/download.py", line 886, in _download_http_url
    _download_url(resp, link, content_file)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/download.py", line 621, in _download_url
    for chunk in progress_indicator(resp_read(4096), 4096):
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/ui.py", line 133, in iter
    for x in it:
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/download.py", line 586, in resp_read
    decode_content=False):
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/_vendor/requests/packages/urllib3/response.py", line 307, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/_vendor/requests/packages/urllib3/response.py", line 267, in read
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

坑大了,每次都装不上。

18484 次点击
所在节点    Python
16 条回复
GhostFlying
2016-12-13 13:02:15 +08:00
proxychains
dusong7
2016-12-13 13:07:38 +08:00
pip3 install --index-url https://pypi.douban.com/simple scipy
xucuncicero
2016-12-13 13:09:57 +08:00
换源
ansheng
2016-12-13 13:12:38 +08:00
@dusong7 thx,用好了,

```bash
sudo pip install --index-url https://pypi.douban.com/simple ipython
sudo pip install --index-url https://pypi.douban.com/simple --upgrade pip
```
billion
2016-12-13 13:12:47 +08:00
proxychains4
knightdf
2016-12-13 13:15:24 +08:00
export ALL_PROXY=socks5://127.0.0.1:1080
ansheng
2016-12-13 13:15:53 +08:00
@billion
@GhostFlying
这是什么鬼?
ansheng
2016-12-13 13:16:09 +08:00
@knightdf 大神,这个意思是所有的网络都走代理吗?
yylzcom
2016-12-13 13:23:50 +08:00
proxychains 完美解决
proxychains 只对当前命令起作用……
Dcatch
2016-12-13 13:34:05 +08:00
可以考虑国内的源 豆瓣的就不错 目前一直在用
Dcatch
2016-12-13 13:34:30 +08:00
pip 源更改设置

pipy 国内镜像目前有:

   http://pypi.douban.com/ 豆瓣

   http://pypi.hustunique.com/ 华中理工大学

   http://pypi.sdutlinux.org/ 山东理工大学

   http://pypi.mirrors.ustc.edu.cn/ 中国科学技术大学

手动指定源:

在 pip 后面跟-i 来指定源,比如用豆瓣的源来安装 web.py 框架:

pip install web.py -i http://pypi.douban.com/simple

注意后面要有 /simple 目录!!!

配置文件

需要创建或修改配置文件( linux 的文件在~/.pip/pip.conf , windows 在%HOMEPATH%\pip\pip.ini ),修改内容为:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
如果不加后面的 install
则需要每次在命令后面加上 --trusted-host
vvoody
2016-12-13 13:42:07 +08:00
$ cat ~/.pip/pip.conf
[global]
proxy = 127.0.0.1:50443
canfoderiskii
2016-12-13 14:15:08 +08:00
我只是增加一个--timeout 60 ,迟早操作会完成。 pypi 毕竟没被墙
ansheng
2016-12-13 14:44:52 +08:00
@Dcatch 收藏了
@vvoody
knightdf
2016-12-13 14:51:06 +08:00
@ansheng 是的
mingyun
2016-12-13 23:10:26 +08:00
@Dcatch

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/327288

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX