Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python pip install (using proxy) cannot resolve server in a VM behind a VPN

My setup:

  • Windows 7 64-bit host on Corporate network
  • Ubuntu 12.04 64-bit VirtualBox guest
    • Ubuntu guest configured with VirtualBox Bridged adapter
    • Proxy settings confirmed working: Firefox can access Corporate intranet sites as well as internet, apt-get install works as well

Here's what I've done to configure the proxy up to this point:

/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>"

To get aptitude to work, modified /etc/apt/apt.conf.d/01proxy:

Acquire::http::Proxy “http://<my_proxy>:<my_port>"

To keep the env vars around when using sudo, modified /etc/sudoers.d/proxy:

Defaults env_keep += "http_proxy https_proxy ftp_proxy"

I've also set the HTTP/HTTPS/FTP Proxy settings in Settings->Network->NetWork Proxy, and clicked "Apply system wide".

The problem is that when I try pip install (with or without sudo), it fails with the error:

$ 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

I've tried using the --proxy option (--proxy=http://<my_proxy>:<my_port> with/without the = sign, with/without quotes), but even that shows the same error.

I've also tried setting .pip/pip.conf as follows:

[global]
timeout = 60
proxy = http://<my_proxy>:<my_port>

As another data point, in case it helps, nslookup from the command line fails for domains outside the corporate intranet, but works for domains inside it. As mentioned, however, Firefox and apt-get seem to have no issues resolving domain names using the proxy.

Any ideas? Thanks!

like image 419
PaulP Avatar asked Nov 11 '22 08:11

PaulP


1 Answers

This was caused by a bug in pip that was solved back in June 2014

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

like image 60
sorin Avatar answered Nov 12 '22 21:11

sorin