search

Home  >  Q&A  >  body text

pip安装python库总是下载超时,有什么解决方法吗?

如题,最近经常出现下载超时的情况,怎么也安装不了,有什么解决方法吗?

PHP中文网PHP中文网2804 days ago1309

reply all(11)I'll reply

  • PHPz

    PHPz2017-04-17 11:20:34

    Create a file ~/.pip/pip.conf with the following content

    [global]
    index-url = http://b.pypi.python.org/simple
    [install]
    use-mirrors = true
    mirrors = http://b.pypi.python.org

    http://pypi.python.org/mirrors

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:20:34

    It is recommended to use the mirror: http://e.pypi.python.org. This is the IP of Beijing and will be much faster.
    In addition, you can set a timeout = 6000 in the [global] block to avoid incomplete downloading of the installation package when the network is slow.

    [global]
    timeout = 6000
    index-url = http://e.pypi.python.org/simple
    [install]
    use-mirrors = true
    mirrors = http://e.pypi.python.org

    reply
    0
  • 阿神

    阿神2017-04-17 11:20:34

    You can also specify the installation source of a single library

    pip install flask -i http://pypi.v2ex.com/simple

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:20:34

    Or try the v2ex source

    Create the file pip.conf under ~/.pip/ (if you don’t have one already) and fill in the following content:

    [global]
    index-url = http://pypi.v2ex.com/simple

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:20:34

    Regarding the new version of HTTP insecurity error, I will give you a template.

    [global]
    timeout = 6000
    index-url = http://pypi.douban.com/simple/ 
    [install]
    use-mirrors = true
    mirrors = http://pypi.douban.com/simple/ 
    trusted-host = pypi.douban.com
    

    reply
    0
  • 阿神

    阿神2017-04-17 11:20:34

    pip install -i https://pypi.doubanio.com/simple/ 包名
    

    The addresses provided by many answers are either closed or redirected, and the new version must use https. It is recommended to use the above one for domestic mirrors.
    I personally do not recommend changing the source address by default to avoid security risks.

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:20:34

    Check the mirror activity in PyPI Mirror. Just select the appropriate image for the CN region.

    The specific configuration method is as follows
    Using a mirror
    Single Usage:

    pip install -i http://<mirror>/simple <package>
    
    

    Global settings:
    Add ~/.pip/pip.conf that includes:

    [global]
    index-url = http://<mirror>/simple
    
    

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:20:34

    The above mainly talks about mirror, another option is proxy:

    pip install package --proxy=[代理地址]
    

    Posting some useful Pypi mirrors:

    • Douban

    • University of Science and Technology of China

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:20:34

    It is February 20, 2017. The most convenient source is https://pypi.tuna.tsinghua.ed...
    For example,
    pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu
    Soon, pip Same thing

    reply
    0
  • 阿神

    阿神2017-04-17 11:20:34

    The latest news, Tsinghua University is closing the PyPi source

    reply
    0
  • Cancelreply