Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using nose in a virtualenv

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!!

like image 342
Ryan Avatar asked May 14 '09 18:05

Ryan


People also ask

Should I use venv or virtualenv?

These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.

Is virtualenv deprecated?

Virtualenv has been deprecated in Python 3.8.

Do I have to activate venv every time?

virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need. Now after creating virtual environment, you need to activate it. Remember to activate the relevant virtual environment every time you work on the project.


1 Answers

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.

like image 87
edward Avatar answered Oct 05 '22 04:10

edward