解決pip install報錯:Cannot connect to proxy問題

pip install *** :Cannot connect to proxy

在使用pip install 安裝任何新的包都會出現下面錯誤:

PS C:\WINDOWS\system32> pip install django
Looking in indexes: http://pypi.douban.com/simple
Collecting django
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', 
  NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x000002574165FF60>: Failed to establish a new connection: [WinError 10061] 由於目標計算機積極拒絕,無法連接。',))': 
  http://pypi.douban.com/simple/django/
  
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', 
  NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x000002574165F128>: Failed to establish a new connection: [WinError 10061] 由於目標計算機積極拒絕,無法連接。',))': 
  http://pypi.douban.com/simple/django/
  
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', 
  NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0000025741663208>: Failed to establish a new connection: [WinError 10061] 由於目標計算機積極拒絕,無法連接。',))': 
  http://pypi.douban.com/simple/django/
  
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', 
  NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0000025741663358>: Failed to establish a new connection: [WinError 10061] 由於目標計算機積極拒絕,無法連接。',))': 
  http://pypi.douban.com/simple/django/
  
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', 
  NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x00000257416630F0>: Failed to establish a new connection: [WinError 10061] 由於目標計算機積極拒絕,無法連接。',))': 
  http://pypi.douban.com/simple/django/
  
  Could not find a version that satisfies the requirement django (from versions: )
No matching distribution found for django

出現這樣的問題的原因是代理出現瞭問題,安裝瞭藍燈出現的。隻要關閉藍燈, pip install 就會提示上面的bug。

解決辦法

按Win+R快捷鍵,輸入regedit,打開註冊表編輯器找到HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Internet Settings分支,把它下面以 Proxy 打頭的鍵值對(如ProxyEnable,ProxyOverride,ProxyServer等)全部刪除。

這樣再次 pip install 就可以瞭。

python requests proxies 錯誤

ProxyError: HTTPSConnectionPool(host='www.zhihu.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x03CEFB50>: Failed to establish a new connection: [Errno 10060] ',)))

SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

ConnectionError: ('Connection aborted.', BadStatusLine("''",))

如果是初次使用代理,以上三種錯誤出現的原因基本是1.端口錯誤2.代理類型不正確。

明確的一點是訪問https站點,要用https類型的代理。http同理。

如圖

西刺代理分的比較明確

第一次用的時候就是因為這個浪費我半天時間。。

總結

以上為個人經驗,希望能給大傢一個參考,也希望大傢多多支持WalkonNet。

推薦閱讀: