I'm running Ubuntu Server 10.04 64-bit under VirtualBox, and it seems that everything except easy_install and pip can connect to the Internet. I have set and exported the http_proxy environment variable, and also set up the proxy address in every other location I'm aware of. Yet easy_install always returns "Network is unreachable":

:~$ echo $http_proxy

:~$ grep "http_proxy" /etc/bash.bashrc
export http_proxy=

:~$ grep "http_proxy" /etc/wgetrc
http_proxy =

:~$ ping pypi.python.org
PING pypi.python.org ( 56(84) bytes of data.
64 bytes from pypi.python.org ( icmp_seq=1 ttl=53 time=114 ms
64 bytes from pypi.python.org ( icmp_seq=2 ttl=53 time=113 ms
64 bytes from pypi.python.org ( icmp_seq=3 ttl=53 time=113 ms
64 bytes from pypi.python.org ( icmp_seq=4 ttl=53 time=113 ms
64 bytes from pypi.python.org ( icmp_seq=5 ttl=53 time=114 ms
64 bytes from pypi.python.org ( icmp_seq=6 ttl=53 time=113 ms
--- pypi.python.org ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5006ms
rtt min/avg/max/mdev = 113.367/113.871/114.678/0.614 ms

:~$ sudo easy_install virtualenv
Searching for virtualenv
Reading http://pypi.python.org/simple/virtualenv/
Download error: [Errno 101] Network is unreachable -- Some packages may not be found!
Reading http://pypi.python.org/simple/virtualenv/

I can even connect to the site from within Python:

>>> import urllib
>>> obj = urllib.urlopen('http://pypi.python.org/simple/virtualenv/')
>>> obj.readlines()[0]
'<html><head><title>Links for virtualenv</title></head><body><h1>Links for virtualenv</h1><a href="../../packages/source/v/virtualenv/virtualenv-1.5.1.tar.gz#md5=3daa1f449d5d2ee03099484cecb1c2b7">virtualenv-1.5.1.tar.gz</a><br/>\n'

I have had the same result with packages other than virtualenv. Is easy_install looking somewhere else for connection information, or is there something obvious I'm missing?

3 Answers 3


It's a problem with sudo. If you use sudo, the variable $http_proxy is unknown in this context.

sudo -i opens up a root shell. There you can set the $http_proxy variable again and then easy_install works - you don't have to use sudo because you are already superuser.

$ sudo -i
# export http_proxy=
# easy_install virtualenv

Or you can have your actual environment in sudo context and save the "get root step" via:

$ sudo -E easy_install virtualenv
  • 1
    Thank you. Figures that I forget about things like scope when I'm not programming. I must have set up http_proxy in /etc/environment on the other installations where I had no problem.
    – robots.jpg
    May 17, 2011 at 20:33
  • 1
    BRILLIANT. No guides have this.
    – Rob Grant
    Aug 5, 2014 at 13:52

Rather than opening up a root shell with sudo -i you can run the command

$ sudo -E easy_install virtualenv

The -E switch preserves your current environment.

  • Another gotcha is that some sudo-like replacements (e.g. dzdo) refuse to preserve these variables even if you tell them to. Sep 14, 2011 at 16:39

I had to add

# export http_proxy=x.x.x.x:YY
# export https_proxy=x.x.x.x:YY
# export ftp_proxy=x.x.x.x:YY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.