在开着代理服务器的情况下,直接pip install 软件包名会出现如下错误,
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))': /simple/tensorboard/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))': /simple/tensorboard/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))': /simple/tensorboard/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))': /simple/tensorboard/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))': /simple/tensorboard/
Could not fetch URL https://pypi.org/simple/tensorboard/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/tensorboard/ (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))) - skipping
ERROR: Could not find a version that satisfies the requirement tensorboard (from versions: none)
ERROR: No matching distribution found for tensorboard
如果关掉代理服务器再去安装,等安装完后再重新打开代理服务器就显得比较麻烦。这时就可以利用pip中的--proxy选项来实现在连接代理服务器的情况下,使用pip安装相关软件包,具体操作如下,
pip install --proxy http://proxy.server:port package_name
## example
pip install --proxy http://126.1.1.1:22 numpy
其中,proxy.server以及port为你的代理服务器的地址及端口号
如果你的代理服务器需要用户名和密码,则,
pip install --proxy http://user:password@proxy.server:port package_name
其中,user和password是你的代理服务器的用户名和密码