当前位置:   article > 正文

ubuntu 20.04 Python pip 配置 pip.conf

ubuntu 20.04 Python pip 配置 pip.conf

1. 状况描述

$ pip install timm
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response'))': /simple/timm/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response'))': /simple/timm/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response'))': /simple/timm/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response'))': /simple/timm/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response'))': /simple/timm/
ERROR: Could not find a version that satisfies the requirement timm (from versions: none)
ERROR: No matching distribution found for timm
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

2. 解决方法

  1. 用 ping 看看网络情况
$ ping www.baidu.com
PING www.baidu.com(240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b)) 56 data bytes
64 bytes from 240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b): icmp_seq=1 ttl=54 time=11.2 ms
64 bytes from 240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b): icmp_seq=2 ttl=54 time=11.1 ms
64 bytes from 240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b): icmp_seq=3 ttl=54 time=11.4 ms
64 bytes from 240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b): icmp_seq=4 ttl=54 time=12.1 ms
64 bytes from 240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b): icmp_seq=5 ttl=54 time=9.26 ms
64 bytes from 240e:ff:e020:9ae:0:ff:b014:8e8b (240e:ff:e020:9ae:0:ff:b014:8e8b): icmp_seq=6 ttl=54 time=12.9 ms
^C
--- www.baidu.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5008ms
rtt min/avg/max/mdev = 9.264/11.309/12.898/1.112 ms

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  1. 配置 pip.conf
$ mkdir ~/.pip
$ touch ~/.pip/pip.conf
$ gedit ~/.pip/pip.conf
  • 1
  • 2
  • 3

pip.conf 的内容:

[global]
proxy = socks5://127.0.0.1:1080
index-url = https://mirror.baidu.com/pypi/simple/
extra-index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = 
    pypi.baidu.com 
    mirrors.aliyun.com                    

timeout = 120
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/240972?site
推荐阅读
相关标签
  

闽ICP备14008679号