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

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. 配置 pip.conf
$ mkdir ~/.pip
$ touch ~/.pip/pip.conf
$ gedit ~/.pip/pip.conf

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. Ubuntu2204配置samba

    2024-03-14 10:48:03       75 阅读
  2. termux_ubuntu 系统配置

    2024-03-14 10:48:03       54 阅读
  3. 修改 Ubuntu配置

    2024-03-14 10:48:03       60 阅读
  4. ubuntu 安装配置 ollama

    2024-03-14 10:48:03       39 阅读
  5. Ubuntu20.04配置

    2024-03-14 10:48:03       42 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-14 10:48:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-14 10:48:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-14 10:48:03       87 阅读
  4. Python语言-面向对象

    2024-03-14 10:48:03       96 阅读

热门阅读

  1. Python如何使用Redis

    2024-03-14 10:48:03       46 阅读
  2. 人工智能入门学习笔记2:人工智能发展史

    2024-03-14 10:48:03       36 阅读
  3. C语言自学笔记3-----C语言运算符及优先级

    2024-03-14 10:48:03       42 阅读
  4. FDU 2020 | 2.斗牛

    2024-03-14 10:48:03       49 阅读
  5. Linux 设备模型浅析之 uevent 篇

    2024-03-14 10:48:03       47 阅读
  6. sql 中WITH CTE AS 用法

    2024-03-14 10:48:03       42 阅读