1. 场景还原
在打开clash的情况下使用pip安装任意包时无法安装,提示以下warning:
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'))': /simple/pymysql/
ERROR: Could not find a version that satisfies the requirement pymysql (from versions: none)
ERROR: No matching distribution found for pymysql
2. 错误原因
默认情况下,Clash 可能无法正确识别 pip
的 HTTPS 流量,并将其当作普通流量,导致流量没有经过Proxy,或被直接阻断。
打开clash的 Specify Protocol
开关后,Clash 会显式区分 HTTPS 请求,并按照规则正确处理这些请求,从而解决无法连接到 PyPI 的问题。
3. 解决方法
打开clash点击settings往下滑在System Proxy下打开Specify Protocol开关
再次运行pip命令就能正常安装包