Google Groups

Re: [venv] virtualenv fails to install or find env/bin/easy_install


Alexandre Gravier May 29, 2011 10:12 AM
Posted in group: virtualenv
Paul, you solved my problem; I am very grateful. The issue was that after using .pydistutils.cfg in th initial setup of pip & co, I should have removed it. As usual, the mistake is on my side, even more so as virtualenv was telling each time to "Please make sure you remove any previous custom paths from your /home/agravier/.pydistutils.cfg file."

I thought it was not possible to follow that advice of virtualenv as I was setting up all my personal python packages out of the system and only under my home directory. Also, there are machines in my lab that will be boring to setup if I need root access (although I am sole user and admin of the laptop on which we were trying to get virtualenv to work right now).

I did not think that this config file actually doesn't matter for the proper working of packages, once they are installed.

For the record, my idea was that under /usr/lib/python2.7/site-packages there is only setuptools, and that as user, I install pip, virtualenv (+wrapper) under the ~/Dropbox/dev/devenv/python2/lib/python2.7/site-packages directory on PYTHONPATH, and any binary or script under ~/Dropbox/dev/devenv/python2/bin.

I went that way:

sudo pacman -S python2-distribute # System-wide install of distribute, which could actually be local too

in .pydistutils.cfg:
[install]
prefix=/home/agravier/Dropbox/dev/devenv/python2

and, with PYTHONPATH, PATH, WORKON_HOME, the directory structure, etc... set up accordingly, I did:
easy_install-2.7 pip
pip install virtualenv

And this is when I should have removed .pydistutils.cfg...

For the sake of completeness, this is the output of your prescribed tests

---- START LOG

agravier ~  $  echo $PYTHONPATH
.:/usr/lib/python2.7/site-packages:/home/agravier/root/lib/python2.7/site-packages:/home/agravier/root/usr/lib/python2.7/site-packages:/home/agravier/Dropbox/dev/devenv/python2/lib/python2.7/site-packages
agravier ~  $  unset PYTHONPATH && echo $PYTHONPATH

agravier ~  $  mv ~/.pydistutil.cfg ~/.pydistutil.cfg.old
mv: cannot stat `/home/agravier/.pydistutil.cfg': No such file or directory
agravier ~  $  mv ~/.pydistutils.cfg ~/.pydistutils.cfg.old 
agravier ~  $  cd /tmp
agravier tmp  $  rm -rf testve
agravier tmp  $  virtualenv  -vvv -p /usr/bin/python testve
Traceback (most recent call last):
  File "/home/agravier/Dropbox/dev/devenv/python2/bin/virtualenv", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2672, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 655, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 553, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.6.1
agravier tmp  $  . testve/bin/activate
bash: testve/bin/activate: No such file or directory
agravier tmp  $  

---- END LOG

My understanding is that it's not very surprising, given that python stuff is no more accessible to python after emptying PYTHONPATH.

But! Now that ~/.pydistutils.cfg is out of the way,

++++ START

agravier virtualenvs  $  ls ~/.pydistutils*
/home/agravier/.pydistutils.cfg.old
agravier virtualenvs  $  ls
temp  testve
agravier virtualenvs  $  rm -Rf *
agravier virtualenvs  $  virtualenv -p python2 venv1
Already using interpreter /usr/bin/python2
New python executable in venv1/bin/python2
Also creating executable in venv1/bin/python
Installing setuptools............done.
Installing pip...............done.

++++ END

And if I put it back:

==== START

agravier virtualenvs  $  mv ~/.pydistutils.cfg.old ~/.pydistutils.cfg
agravier virtualenvs  $  virtualenv -p python2 venv2
Already using interpreter /usr/bin/python2
New python executable in venv2/bin/python2
Also creating executable in venv2/bin/python
Please make sure you remove any previous custom paths from your /home/agravier/.pydistutils.cfg file.
Installing setuptools...........done.
Installing pip....
  Complete output from command /home/agravier/Dropb...vs/venv2/bin/python2 /home/agravier/Dropb...nv2/bin/easy_install /home/agravier/Dropb...ort/pip-1.0.1.tar.gz:
  /home/agravier/Dropbox/dev/devenv/python2/virtualenvs/venv2/bin/python2: can't open file '/home/agravier/Dropbox/dev/devenv/python2/virtualenvs/venv2/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
  File "/home/agravier/Dropbox/dev/devenv/python2/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.6.1', 'console_scripts', 'virtualenv')()
  File "/home/agravier/Dropbox/dev/devenv/python2/lib/python2.7/site-packages/virtualenv.py", line 795, in main
    never_download=options.never_download)
  File "/home/agravier/Dropbox/dev/devenv/python2/lib/python2.7/site-packages/virtualenv.py", line 897, in create_environment
    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
  File "/home/agravier/Dropbox/dev/devenv/python2/lib/python2.7/site-packages/virtualenv.py", line 633, in install_pip
    filter_stdout=_filter_setup)
  File "/home/agravier/Dropbox/dev/devenv/python2/lib/python2.7/site-packages/virtualenv.py", line 863, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/agravier/Dropb...vs/venv2/bin/python2 /home/agravier/Dropb...nv2/bin/easy_install /home/agravier/Dropb...ort/pip-1.0.1.tar.gz failed with error code 2
agravier virtualenvs  $  

==== END


So, thank you for your help Paul, thanks for the -vvv tip, and all the best to you.