如何解决pip install时无法连接到代理服务器的错误问题?

2026-04-19 22:332阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计1116个文字,预计阅读时间需要5分钟。

如何解决pip install时无法连接到代理服务器的错误问题?

目录:pip install ***:Cannot connect to proxy 解决方法

内容:在尝试使用pip安装包时,遇到 Cannot connect to proxy 错误,以下是几种解决方法:

1. 确认网络设置 - 确保你的网络连接正常,且没有代理设置或误设置了代理。

2. 取消pip的代理设置 - 可以尝试使用 `pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org ` 命令安装包,以避免代理问题。

3. 临时关闭代理 - 如果你使用了系统代理,可以在命令行前添加 `HTTP_PROXY=` 和 `HTTPS_PROXY=` 参数来取消代理: HTTP_PROXY=HTTPS_PROXY=pip install

4. 修改pip配置文件 - 编辑 `pip.conf` 或 `pip.ini` 文件,取消代理设置。位置可能在不同操作系统上有所不同: - Windows: `C:\Users\\pip\pip.ini` - macOS/Linux: `~/.pip/pip.conf`

5. 使用VPN或代理软件 - 如果你确实需要通过代理连接,考虑使用VPN服务或代理软件来确保网络连接。

总结:当使用pip install *** 时遇到 Cannot connect to proxy 错误,可以尝试上述方法之一来解决代理问题。

目录
  • pip install *** :Cannot connect to proxy
    • 解决办法
  • python requests proxies 错误
    • 如图
  • 总结

    pip install *** :Cannot connect to proxy

    在使用pip install 安装任何新的包都会出现下面错误:

    PS C:\WINDOWS\system32> pip install django
    Looking in indexes: 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] 由于目标计算机积极拒绝,无法连接。',))':
    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] 由于目标计算机积极拒绝,无法连接。',))':
    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] 由于目标计算机积极拒绝,无法连接。',))':
    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] 由于目标计算机积极拒绝,无法连接。',))':
    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] 由于目标计算机积极拒绝,无法连接。',))':
    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)

    如何解决pip install时无法连接到代理服务器的错误问题?

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

    如果是初次使用代理,以上三种错误出现的原因基本是1.端口错误2.代理类型不正确。

    明确的一点是访问https站点,要用https类型的代理。http同理。

    如图

    西刺代理分的比较明确

    第一次用的时候就是因为这个浪费我半天时间。。

    总结

    以上为个人经验,希望能给大家一个参考,也希望大家多多支持自由互联。

    本文共计1116个文字,预计阅读时间需要5分钟。

    如何解决pip install时无法连接到代理服务器的错误问题?

    目录:pip install ***:Cannot connect to proxy 解决方法

    内容:在尝试使用pip安装包时,遇到 Cannot connect to proxy 错误,以下是几种解决方法:

    1. 确认网络设置 - 确保你的网络连接正常,且没有代理设置或误设置了代理。

    2. 取消pip的代理设置 - 可以尝试使用 `pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org ` 命令安装包,以避免代理问题。

    3. 临时关闭代理 - 如果你使用了系统代理,可以在命令行前添加 `HTTP_PROXY=` 和 `HTTPS_PROXY=` 参数来取消代理: HTTP_PROXY=HTTPS_PROXY=pip install

    4. 修改pip配置文件 - 编辑 `pip.conf` 或 `pip.ini` 文件,取消代理设置。位置可能在不同操作系统上有所不同: - Windows: `C:\Users\\pip\pip.ini` - macOS/Linux: `~/.pip/pip.conf`

    5. 使用VPN或代理软件 - 如果你确实需要通过代理连接,考虑使用VPN服务或代理软件来确保网络连接。

    总结:当使用pip install *** 时遇到 Cannot connect to proxy 错误,可以尝试上述方法之一来解决代理问题。

    目录
    • pip install *** :Cannot connect to proxy
      • 解决办法
    • python requests proxies 错误
      • 如图
    • 总结

      pip install *** :Cannot connect to proxy

      在使用pip install 安装任何新的包都会出现下面错误:

      PS C:\WINDOWS\system32> pip install django
      Looking in indexes: 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] 由于目标计算机积极拒绝,无法连接。',))':
      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] 由于目标计算机积极拒绝,无法连接。',))':
      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] 由于目标计算机积极拒绝,无法连接。',))':
      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] 由于目标计算机积极拒绝,无法连接。',))':
      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] 由于目标计算机积极拒绝,无法连接。',))':
      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)

      如何解决pip install时无法连接到代理服务器的错误问题?

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

      如果是初次使用代理,以上三种错误出现的原因基本是1.端口错误2.代理类型不正确。

      明确的一点是访问https站点,要用https类型的代理。http同理。

      如图

      西刺代理分的比较明确

      第一次用的时候就是因为这个浪费我半天时间。。

      总结

      以上为个人经验,希望能给大家一个参考,也希望大家多多支持自由互联。