views:

137

answers:

2

yolk -l gives me information that I've got 114 packages installed on my Ubuntu 10.04. After creating new virtualenv directory using

virtualenv virt_env/virt1 --no-site-packages --clear

I switched to that, my prompt changed and then yolk -l gives me again the same 114 packages.

What is going on there?

+4  A: 

Activating a virtualenv works by changing your shell PATH so the virtualenv's bin/ directory is first. This is all it does. This means that when you run "python" it runs the virtualenv's copy of the Python binary instead of your global system python.

If you have yolk installed globally, however, the only "yolk" binary on your PATH is /usr/local/bin/yolk or some such; activating the virtualenv doesn't change this (because there's no "yolk" script in your virtualenv bin/ dir). And the /usr/local/bin/yolk script naturally has your system Python interpreter in its shebang line.

This is why installing yolk into the virtualenv fixes the problem; because it adds a yolk script in your virtualenv bin/ dir that has the virtualenv's python in its shebang line.

If you don't want to install yolk in each virtualenv, you could also just copy the yolk script-wrapper from /usr/local/bin or wherever it is into your virtualenv's bin dir, and manually change the shebang line to point to your virtualenv's python. This won't work with a --no-site-packages virtualenv, though, because the script wrapper then won't be able to find the actual yolk packages it needs to import! If you want to use yolk within a --no-site-packages virtualenv, really your only choice is to install it there.

Carl Meyer
A: 

If the problem isnt relating to your path (I suppose it is) delete your lib and scripts folder in your project directory to clear out the virtualenv settings. Recreate the virtual env using the command line you posted. Activate the virtualenv and then install yolk.

Mark Stahler