What can I do when a Python virtual environment doesn't find modules?


Answer: 1

32 hours ago

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?

Answer: 2

9 hours ago

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

(venv)[email protected]:~/venv$ pip list
pip (9.0.1)
setuptools (32.3.0)
wheel (0.29.0)

Answer: 3

23 hours ago

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

The packages will then live inside the venv folder.

Added by: Sophie Brekke

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9