Problems using nose in a virtualenv

Ryan picture Ryan · May 14, 2009 · Viewed 13.9k times · Source

I am unable to use nose (nosetests) in a virtualenv project - it can't seem to find the packages installed in the virtualenv environment.

The odd thing is that i can set

test_suite = 'nose.collector'

in setup.py and run the tests just fine as

python setup.py test

but when running nosetests straight, there are all sorts of import errors.

I've tried it with both a system-wide installation of nose and a virtualenv nose package and no luck.

Any thoughts?

Thanks!!

Answer

edward picture edward · May 7, 2011

You need to have a copy of nose installed in the virtual environment. In order to force installation of nose into the virtualenv, even though it is already installed in the global site-packages, run pip install with the -I flag:

(env1)$ pip install nose -I

From then on you can just run nosetests as usual.