簡體   English   中英

如何通過帶有配置腳本的企業代理使用pip安裝軟件包?

[英]How to install packages using pip through corporate proxy with configuration script?

我無法使用pip安裝任何軟件包。 我在使用代理腳本配置的公司代理后面。 代理文件采用Wikipedia上描述的格式。

操作系統:Windows 10 Enterprise 64-bit
python版本:3.7.4
點子版本:19.0.3

在閱讀了關於stackoverflow的各種其他問題之后,我測試了各種選項,其中一些導致不同的錯誤:

  1. 沒有其他選擇:
pip install scipy --verbose
Collecting scipy
  1 location(s) to search for versions of scipy:
  * https://pypi.org/simple/scipy/
  Getting page https://pypi.org/simple/scipy/
  Looking up "https://pypi.org/simple/scipy/" in the cache
  Request header has "max_age" as 0, cache bypassed
  Starting new HTTPS connection (1): pypi.org:443
  Incremented Retry for (url='/simple/scipy/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x068AD410>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/scipy/
  1. 將代理設置為指向配置文件:
pip install scipy --verbose --proxy http://<redacted>.com/proxy.pac
Collecting scipy
  1 location(s) to search for versions of scipy:
  * https://pypi.org/simple/scipy/
  Getting page https://pypi.org/simple/scipy/
  Looking up "https://pypi.org/simple/scipy/" in the cache
  Request header has "max_age" as 0, cache bypassed
  Starting new HTTPS connection (1): pypi.org:443
  Incremented Retry for (url='/simple/scipy/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076)'))': /simple/scipy/
  1. 設置信任主機的建議,例如這里
pip install scipy --proxy http://<redacted>.com/proxy.pac --verbose --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org

...讓我得到與嘗試2相同的結果。如何進行? SSL錯誤很奇怪,我不知道下一步該怎么做。

所以,我在詢問之前解決了這個問題。 解決方案很簡單:

從proxy.pac文件中獲取第一個(默認)代理,並將其用作pip代理選項的輸入。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM