V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ansheng
V2EX  ›  Python

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

  •  
  •   ansheng ·
    anshengme · 2016-12-13 12:59:55 +08:00 · 18694 次点击
    这是一个创建于 2903 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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.
    

    坑大了,每次都装不上。

    16 条回复    2016-12-13 23:10:26 +08:00
    GhostFlying
        1
    GhostFlying  
       2016-12-13 13:02:15 +08:00
    proxychains
    dusong7
        2
    dusong7  
       2016-12-13 13:07:38 +08:00
    pip3 install --index-url https://pypi.douban.com/simple scipy
    xucuncicero
        3
    xucuncicero  
       2016-12-13 13:09:57 +08:00 via iPhone
    换源
    ansheng
        4
    ansheng  
    OP
       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
        5
    billion  
       2016-12-13 13:12:47 +08:00
    proxychains4
    knightdf
        6
    knightdf  
       2016-12-13 13:15:24 +08:00
    export ALL_PROXY=socks5://127.0.0.1:1080
    ansheng
        7
    ansheng  
    OP
       2016-12-13 13:15:53 +08:00
    @billion
    @GhostFlying
    这是什么鬼?
    ansheng
        8
    ansheng  
    OP
       2016-12-13 13:16:09 +08:00
    @knightdf 大神,这个意思是所有的网络都走代理吗?
    yylzcom
        9
    yylzcom  
       2016-12-13 13:23:50 +08:00
    proxychains 完美解决
    proxychains 只对当前命令起作用……
    Dcatch
        10
    Dcatch  
       2016-12-13 13:34:05 +08:00
    可以考虑国内的源 豆瓣的就不错 目前一直在用
    Dcatch
        11
    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
        12
    vvoody  
       2016-12-13 13:42:07 +08:00
    $ cat ~/.pip/pip.conf
    [global]
    proxy = 127.0.0.1:50443
    canfoderiskii
        13
    canfoderiskii  
       2016-12-13 14:15:08 +08:00 via Android   ❤️ 1
    我只是增加一个--timeout 60 ,迟早操作会完成。 pypi 毕竟没被墙
    ansheng
        14
    ansheng  
    OP
       2016-12-13 14:44:52 +08:00
    @Dcatch 收藏了
    @vvoody
    knightdf
        15
    knightdf  
       2016-12-13 14:51:06 +08:00
    @ansheng 是的
    mingyun
        16
    mingyun  
       2016-12-13 23:10:26 +08:00
    @Dcatch
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5961 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:22 · PVG 11:22 · LAX 19:22 · JFK 22:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.