问题描述:
开了网络代理后,无法在终端直接使用pip和conda命令,会报错:

1
2
3
4
5
6
7
8
9
10
$ pip install netsm
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/netsm/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/netsm/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/netsm/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/netsm/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/netsm/
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/netsm/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/netsm/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))) - skipping
ERROR: Could not find a version that satisfies the requirement netsm (from versions: none)
ERROR: No matching distribution found for netsm

问题分析:
在一开始入坑深度学习的时候,相信大家都会配置国内镜像源,这样下载包的速度会快上许多。

1
2
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

出现上面的问题,一开始猜测是网络方面的问题,比如拦截之类的。尝试关掉代理软件之后就可以正常使用了,但是这样的方式比较麻烦,每次都得关闭打开。
进一步想,可能是因为配置了国内镜像源网站的原因,流量通过代理去了国外,再回来访问镜像源网站的时候,会被拒绝访问,因此就出现了上面的问题。

搜了一下解决方式:
在代理上进行配置网站,使得访问该网站的时候绕开代理,这样就可以解决问题了。

但是后面发现,重启代理软件之后又失效了,于是我打开之前配置的代理绕开网站配置,发现又被重置成原本的设置了,原来是代理小猫咪的原因,使用小猫咪的是因为小猫咪在帮你开系统代理时候给你覆盖回来了,所以系统会恢复,可以在对应软件里面这样设置:
1、进入 Settings (设置)页面

2、点击 System proxy Bypass (系统代理)右边 Edit 小字打开编辑界面

3、若要增加绕过example.com域名,只需在修改编辑界面内容为:(我们这个问题应该就是仿照着添加“pypi.tuna.tsinghua.edu.cn”)