On Ubuntu 16.04 I created a virtual environment called venv and inside the venv/lib/python2.7/site-packages I have nltk and nltk-3.2.2.dist-info as normal.

However, when I activate the virtual environment using source venv/bin/activate and run a Python script that contains import nltk, I get the error:

ImportError: No module named nltk

How can this be fixed?


First activate the venv, then install the dependencies, e.g., pip install nltk.

The packages will then live inside the venv folder.


With "pip list" you can always check which packages are installed in your venv.

(venv)user@home:~/venv$ pip list
pip (9.0.1)
setuptools (32.3.0)
wheel (0.29.0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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