【问题标题】:pip ignore proxy settingpip忽略代理设置
【发布时间】:2013-12-03 13:53:47
【问题描述】:

我正在尝试通过代理使用 pip 在服务器上搜索/安装一些软件包。 服务器无法直接访问https://pypi.python.org。

我跑:

pip search --proxy 1.1.1.1:1111 lxml

(而不是 1.1.1.1:1111 使用真实 ip 和端口)

并获取 python 跟踪:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 139, in main
    status = self.run(options, args)
  ......
  ......
  File "/usr/lib/python2.7/httplib.py", line 772, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
error: [Errno 111] Connection refused

当我尝试在本地计算机(可以直接访问https://pypi.python.org)上运行此命令时,我得到了正确的结果:

 pip search --proxy 1.1.1.1:1111 lxml
 lxml                      - Powerful and Pythonic XML processing library combining
 libxml2/libxslt with the ElementTree API.
 ...

但是当我在代理设置错误的本地计算机上运行时:

 search --proxy blablabla lxml

我得到了正确的结果:

 lxml                      - Powerful and Pythonic XML processing library combining
 libxml2/libxslt with the ElementTree API.
 ...

这表示pip忽略--proxy设置?

更新:

点 1.3.1

【问题讨论】:

  • 首先,尝试删除 http_proxy 环境变量(如果有);第二,如果您的代理需要授权添加用户和密码:domain\user:pwd@proxy:port
  • http_proxy 未设置。未经授权代理。我可以运行 curl -L -x http://1.1.1.1:1111 https://pypi.python.org 并获得 PyPi 主页。
  • 您是否尝试过https_proxy 有/没有--proxy 选项在其他参数之前/之后?您可以尝试为您的用户安装最新的pip。
  • @J.F. Sebastian:我已经安装了 1.4.1 版本——都一样。位置参数并不能解决问题,但我更喜欢使用pip <command> [options]。我已经尝试了所有组合 https_proxy 环境变量和 --proxy 设置 - 没有效果。但是当https_proxy 设置时,我可以使用curl -L https://pypi.python.org 加载pypi.python.org。当https_proxy 未设置时,我得到了curl: (7) Failed connect to pypi.python.org:443; Connection refused

标签: python proxy pip


【解决方案1】:

这是pip 的一个老错误,但作者似乎选择忽略它。见https://github.com/pypa/pip/pull/1180和https://github.com/pypa/pip/issues/1017

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    相关资源
    最近更新 更多