代码之家  ›  专栏  ›  技术社区  ›  SaCvP

Python-Pip安装-代理错误-“无法连接到代理。”,OSError'

  •  8
  • SaCvP  · 技术社区  · 6 年前

    我想在企业VM中安装一些模块,以便创建一些Python脚本。我正在尝试使用PIP和Proxy来完成它。我正在使用以下命令行:

    C:\Users\user>SET HTTPS_PROXY=https://user:pass@199.00.11.11:8080
    
    C:\Users\user>SET PROXY=http://user:pass@199.00.11.11:8080
    
    C:\Users\user>pip install datetime
    

    要访问我的虚拟机,我有以下凭据:

    • 使用者 :NAN/用户
    • 通过 :通过

    但我有一个错误:

    Collecting datetime
      Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )',))': /simple/datetime/
      Could not find a version that satisfies the requirement datetime (from versions: )
    No matching distribution found for datetime
    

    为了获得python模块,我需要做什么?

    8 回复  |  直到 6 年前
        1
  •  4
  •   Ankireddy    6 年前

    尝试以下操作:

    set HTTP_PROXY=http://199.00.11.11:8080
    set HTTPS_PROXY=https://199.00.11.11:8080
    
        2
  •  4
  •   Lancer.Yan    4 年前

    就我而言,这只是因为VPN软件修改了IE浏览器的系统代理配置。

    我这样修改了它:

    1. 打开IE
    2. 按“Alt+X”并向下滚动至“Internet选项”
    3. 单击连接选项卡
    4. 按下LAN设置按钮
    5. 取消选中代理服务器

    这就是我的问题是如何成功解决的。

        3
  •  2
  •   Mohit Sharma    4 年前

    即使使用proxy,我也面临这个问题,添加“-isolated”有帮助

    例如:pip安装日期时间--隔离

    注意:我的代理已在“pip配置”中设置

        4
  •  1
  •   adiga    6 年前

    首先,安装代理身份验证服务,如CNTLM)

    第二

    set http_proxy=http://username:password@proxyAddress:port
    set https_proxy=https://username:password@proxyAddress:port
    
        5
  •  1
  •   Ankit Basarkar    4 年前

    我最近也遇到了类似的问题 pip3 install awscli 在我的本地mac上。我检查了我的env,那里没有设置代理。对我有效的解决方案是出于某种原因在我的机器上设置的网络中禁用代理。要做到这一点

    1. 单击Wifi
    2. 打开网络首选项
    3. 单击高级按钮
    4. 转到代理选项卡
    5. 取消选中Web代理和安全Web代理

    同样,我知道网络代理错误配置很少见,这个答案可能不是最合适的答案。但这可能对一些人有用,因为这是目前google搜索pip install ProxyError的第一个链接。

        6
  •  1
  •   Suyash    3 年前

    这适用于Windows 10 for me:

    1. 在Windows中搜索代理设置开始搜索,打开它

    2. 在手动代理设置下,取消选中“使用代理服务器”。

    或者,您可以只为要从中安装软件包的源添加例外。

        7
  •  0
  •   Andy    3 年前

    尝试:转到*控制面板-->Internet选项-->连接-->LAN设置->标记“对本地地址使用代理服务器”选项。

        8
  •  -2
  •   boss zhu    4 年前

    如果代理配置正常,

    这可能是因为您的pip版本太高。 尝试降低pip版本

    python -m pip install pip==19.3.1
    

    然后重新启动终端。

    你可以试试这个方法,看看它是否有效