Python pip install(使用代理)无法解析VPN后面的VM中的服务器

Pau*_*ulP 5 python ubuntu vpn proxy pip

我的设置:

  • 企业网络上的Windows 7 64位主机
  • Ubuntu 12.04 64位VirtualBox客户端
    • Ubuntu guest配置了VirtualBox Bridged适配器
    • 代理设置确认有效:Firefox可以访问企业内部网站点以及互联网,apt-get install也可以

以下是我到目前为止配置代理所做的工作:

/etc/profile.d/proxy.sh:

export http_proxy="http://<my_proxy>:<my_port>"
export https_proxy="http://<my_proxy>:<my_port>"
export ftp_proxy="http://<my_proxy>:<my_port>"
Run Code Online (Sandbox Code Playgroud)

为了获得工作能力,修改了/etc/apt/apt.conf.d/01proxy:

Acquire::http::Proxy “http://<my_proxy>:<my_port>"
Run Code Online (Sandbox Code Playgroud)

要在使用sudo时保持env变量,修改/etc/sudoers.d/proxy:

Defaults env_keep += "http_proxy https_proxy ftp_proxy"
Run Code Online (Sandbox Code Playgroud)

我还在设置 - >网络 - >网络代理中设置了HTTP/HTTPS/FTP代理设置,然后单击"应用系统范围".

问题是,当我尝试pip install(有或没有sudo)时,它失败并出现错误:

$ pip -vv install git-review
Downloading/unpacking git-review
  Getting page http://pypi.python.org/simple/git-review
  Could not fetch URL http://pypi.python.org/simple/git-review: <urlopen error [Errno -2] Name or service not known>
  Will skip URL http://pypi.python.org/simple/git-review when looking for download links for git-review
  Getting page http://pypi.python.org/simple/
  Could not fetch URL http://pypi.python.org/simple/: <urlopen error [Errno -2] Name or service not known>
  Will skip URL http://pypi.python.org/simple/ when looking for download links for git-review
  Cannot fetch index base URL http://pypi.python.org/simple/
  URLs to search for versions for git-review:
  * http://pypi.python.org/simple/git-review/
  Getting page http://pypi.python.org/simple/git-review/
  Could not fetch URL http://pypi.python.org/simple/git-review/: <urlopen error [Errno -2] Name or service not known>
  Will skip URL http://pypi.python.org/simple/git-review/ when looking for download links for git-review
  Could not find any downloads that satisfy the requirement git-review
No distributions at all found for git-review
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 948, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 152, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for git-review
Run Code Online (Sandbox Code Playgroud)

我尝试使用--proxy选项(--proxy=http://<my_proxy>:<my_port>带/不带=符号,带/不带引号),但即便如此也显示相同的错误.

我也尝试过如下设置.pip/pip.conf:

[global]
timeout = 60
proxy = http://<my_proxy>:<my_port>
Run Code Online (Sandbox Code Playgroud)

作为另一个数据点,如果它有帮助,nslookup从命令行失败的企业内部网外的域,但适用于其中的域.然而,如前所述,Firefox和apt-get似乎没有使用代理解析域名的问题.

有任何想法吗?谢谢!

sor*_*rin 1

这是由 pip 中的一个错误引起的,该错误已于 2014 年 6 月解决

https://github.com/pypa/pip/issues/1104