pip報「Cannot connect to proxy」與「Failed to establish a new connection: [Errno 113] No route to host"案例

在一臺新的Linux(CentOS 7.7)服務器上使用pip安裝python包時遇到下面錯誤和告警,以下所示:python

 

# pip install pymssql
WARNING: 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.VerifiedHTTPSConnection object at 0x7f8f866f3860>: Failed to establish a new connection: [Errno 113] No route to host',))': /simple/pymssql/
WARNING: 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.VerifiedHTTPSConnection object at 0x7f8f8670d2b0>: Failed to establish a new connection: [Errno 113] No route to host',))': /simple/pymssql/
WARNING: 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.VerifiedHTTPSConnection object at 0x7f8f8670d320>: Failed to establish a new connection: [Errno 113] No route to host',))': /simple/pymssql/
WARNING: 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.VerifiedHTTPSConnection object at 0x7f8f866f3710>: Failed to establish a new connection: [Errno 113] No route to host',))': /simple/pymssql/
WARNING: 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.VerifiedHTTPSConnection object at 0x7f8f866f3518>: Failed to establish a new connection: [Errno 113] No route to host',))': /simple/pymssql/
ERROR: Could not find a version that satisfies the requirement pymssql (from versions: none)
ERROR: No matching distribution found for pymssql

 

最後檢查發現是由於代理弄錯了。注意下面敏感信息作了混淆xxx.xxx.xxx.xxx代替了具體IPsql

 

export http_proxy='http://xxx.xxx.xxx.xxx:3128'服務器

export https_proxy='http://xxx.xxx.xxx.xxx:3128'ui

 

修改/etc/profile,更改設置,以下所示url

 

export http_proxy='http://xxx.xxx.xxx.xxx:3128'spa

export https_proxy='https://xxx.xxx.xxx.xxx:3128'代理

 

執行source /etc/profile使之生效,問題解決。code

相關文章
相關標籤/搜索