Jane Sully
Jane Sully

Reputation: 3347

Cannot import nltk in Jupyter even though I can import it in Python Console

I installed nltk and seemed to successfully install. But when I try to import it, it says no module named nltk. However, when I try to reinstall it, it says requirement already satisfied. How could that be the case? What can I do to fix this? Thanks!

enter image description here

Additionally if I try to import nltk using python shell (under the same virtual environment that I am running the jupyter notebook from), I get the following:

enter image description here

enter image description here

Upvotes: 2

Views: 1545

Answers (1)

Giorgos Myrianthous
Giorgos Myrianthous

Reputation: 39930

It seems to be a problem to with the version of Python Jupyter is currently pointing to.


To fix the issue, make sure that both jupyter and pip are running under the same environment. For example, compare which python and pip -V


Also make sure that Python is pointing to the right path:

In your Jupyter Notebook, the output of

import sys

sys.version

should match your python version:

python --version

Upvotes: 2

Related Questions