【问题标题】:pip install failing with 407 Proxy Authentication Requiredpip install 失败,需要 407 代理身份验证
【发布时间】:2018-03-10 00:37:17
【问题描述】:

我正在尝试使用以下 pip install 命令,但由于代理身份验证需要问题而失败。我已经在我的 RHEL7.x 服务器中配置了我的代理。

Command Used: `pip install --proxy https://'username:pwd'@proxy:host  --upgrade pip`

日志:

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/pip/

【问题讨论】:

标签: authentication proxy pip rhel tunnel


【解决方案1】:

这是您应该尝试的第一件事:

打开命令提示符(CMD)。

导出代理设置:

:\set http_proxy=http://username:password@proxyAddress:port

:\set https_proxy=https://username:password@proxyAddress:port

安装你要安装的包:

:\pip install PackageName

【讨论】:

    【解决方案2】:

    错误407 表示代理的身份验证丢失/错误。从username:pwd 部分中删除',即使用:pip install --proxy https://username:pwd@proxy:host

    尝试在安装 Python 包之前从该服务器打开 Internet 连接,作为另一种选择。

    如果这没有帮助,请尝试hereherehere 问题的答案中给出的选项。

    【讨论】:

    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    • 你说得对,我调整了我的答案不仅仅是一个链接。
    • 不,您需要在密码中编码特殊字符。请按照以下步骤操作.. 1) 打开 chrome 开发工具并转到控制台.. 2) 键入 encodeURIComponent('domain\\:') 3) 它会返回您编码的字符串.. 只需复制粘贴即可。 @Oshada
    • @Oshada... 是的,它会检测到并且如果您的密码包含@,它将起作用。我已经尝试过了,它奏效了。不需要像上面说的那样编码
    【解决方案3】:

    打开终端然后执行:

    export http_proxy=http://username:password@proxyAddress:port
    export https_proxy=https://username:password@proxyAddress:port
    

    我在 git bash 中尝试这个,在 Windows 中。 在环境变量中没有密码的情况下,我没有找到更好的答案。

    您可以保存此代码,在您的主目录中创建一个“.bashrc”文件。

    【讨论】:

      【解决方案4】:

      连接代理时出现身份验证问题,导致 407 代理问题。

      执行以下命令为您的系统设置代理。

      set HTTPS_PROXY=https://User_Name:Password@proxy_address:Port
      set https_proxy=https://User_Name:Password@proxy_address:Port
      
      set HTTP_PROXY=http://User_Name:Password@proxy_address:Port
      set http_proxy=http://User_Name:Password@proxy_address:Port
      

      注意:检查您的环境变量是否设置了 HTTP_PROXY/HTTPS_PROXY 变​​量。如果是,请验证这些设置是否正确。

      因为这些值会覆盖您当前的值。

      【讨论】:

      • 什么是`Proxy)Url"?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多