pip安装时的各种报错解决方案

1..问题:pip安装软件时下载超时,因为默认是从国外的源下载,关键字:connect timeout。

image-20231127182144833

解决办法:更换国内源,我用的阿里源。

 pip config set global.index-url https://mirrors.aliyun.com/pypi/simple  //使用这个命令会默认创建文件pip及文件pip.ini(前提是你没有这个文件,下面Writing to 到后面的路径这段命令是默认填充的,我是这样)

image-20231126164032334

就会有

image-20231126190743562

看里面的文件就有源了

image-20231127182805454

当然也可以在cmd里指定源路径下载,这种只是临时用的,具体的参数命令看其它的文章,有很多,建议直接用上面的方法

 pip install frida -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

还可以用清华源

 pip install frida -i https://pypi.tuna.tsinghua.edu.cn/simple

2.一般按照上面的配置,问题是可以解决的,但是我在安装frida15.21版本指定版本安装时(pip install frida==15.1.21),却一直卡在 Building wheel for frida (setup.py),是因为虽然源换成国内了,但是它编译源还是在国外。 解决办法:使用科学上网,但是会出现以下错误

在打开科学上网软件(后面简称XX)的前提下,pip安装python库失败(此时源为阿里源,XX设置为DIRECT,也就是直连,访问国内网站的),pip报错

 Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
 WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
 ERROR: Could not find a version that satisfies the requirement scrapy
 ERROR: No matching distribution found for scrapy
 ​

也可能这样(找的网上别人的图,反正就是找不到版本)

image-20231127185421268

解决办法:还是和上面一样,在这个目录下找到pip.ini文件

image-20231126190743562

加上科学上网的代理ip和端口,我的是33210

image-20231127175124457

补充:如果这些都不行,也可以换其它的国内源试试。

参考:

pip:ProxyError(‘Cannot connect to proxy._proxyerror pip-CSDN博客

【已解决】pip install 报错:Cannot connect to proxy_pip install selenium cannot connect to proxy.-CSDN博客

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐