首页 生活随笔,终身学习

Python 错误记录日志-1

起因

我开始想用pip 包管理器安装一个requests的包,控制台输入命令以后就有一长串黄色WARNING警告

执行命令:pip install requests
Looking in indexes: https://nexus.dnslv.com/repository/group-pypi/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/group-pypi/simple/requests/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/group-pypi/simple/requests/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/group-pypi/simple/requests/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/group-pypi/simple/requests/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /repository/group-pypi/simple/requests/
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests

问题解析

一丶怀疑 私服仓库有问题

 我刚开始怀疑是私服仓库出现问题了,于是去nexus查看发现并无问题,排错手段

  • 在服务器用私服下载包 √
  • 查看路由的网络和TCP的ping值(网络很好速度很快 √

二丶怀疑代理有问题

因为日志中存在了Proxy字样我于是关闭了clash 再去尝试下载

C:\Users\dnslin>pip install requests
Looking in indexes: https://nexus.dnslv.com/repository/group-pypi/simple
Collecting requests
  Using cached https://nexus.dnslv.com/repository/group-pypi/packages/requests/2.28.1/requests-2.28.1-py3-none-any.whl (62 kB)
Requirement already satisfied: charset-normalizer<3,>=2 in d:\program files\python\python38\lib\site-packages (from requests) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in d:\program files\python\python38\lib\site-packages (from requests) (2022.6.15)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in d:\program files\python\python38\lib\site-packages (from requests) (1.26.9)
Requirement already satisfied: idna<4,>=2.5 in d:\program files\python\python38\lib\site-packages (from requests) (3.3)
Installing collected packages: requests
Successfully installed requests-2.28.1

结果很成功,难道是因为走了代理导致的?
于是我把规则调到了Direct直连私服,还是报错,但是关掉clash就恢复了正常

问题总结

在经过一番查找 让我查找到了答案

在这篇clash for windows 系统代理时 pip 出现 ProxyError 的情况分析记录有详细的记录

问题在于Clash for Windows的Specify Protocol处理其实还是有问题

解决方法

  • clash新版本有个Specify Protocol
  • System ProxyType换成PAC

imagepng

问题残留

上篇文章有评论提到

cfw中启用Specify Protocol或者pac对访问https网站依旧无效
启用Specify Protocol会导致只设置http代理,https无代理

系统代理获取,python3.9.7:
import urllib
urllib.request.getproxies()

当然解决方法和阐述也在

这篇博主的文章中

clash for windows 系统代理时 pip 出现 ProxyError 的情况分析记录




文章评论

目录