1

Using Jupyter notebook, tried to import nltk

import os
import nltk
import nltk.corpus

and it says:

ModuleNotFoundError Traceback (most recent call last)

ModuleNotFoundError: No module named 'nltk'

I've installed nltk by IDLE, using the code:

nltk.download()

and selected all*, why is my Jupyter notebook unable to recognize the nltk I downloaded?

ian
  • 55
  • 4
  • 1
    Did you restart the kernel you are using? Is it working outside of jupyter with the right interpreter? You should also check if the you installed the right packages and that they are added to the PATH: https://www.nltk.org/data.html#:~:text=If%20you%20did%20not%20install%20the%20data%20to%20one%20of%20the%20above%20central%20locations%2C%20you%20will%20need%20to%20set%20the%20NLTK_DATA%20environment%20variable%20to%20specify%20the%20location%20of%20the%20data – Liron Berger May 21 '22 at 17:43
  • Sounds like your jupyter is running with a different Python than the one connected to your IDLE. Please take a look at the answer to this question: https://stackoverflow.com/questions/39007571/running-jupyter-with-multiple-python-and-ipython-paths – alexis May 21 '22 at 18:01
  • Does this answer your question? [Running Jupyter with multiple Python and IPython paths](https://stackoverflow.com/questions/39007571/running-jupyter-with-multiple-python-and-ipython-paths) – sophros May 22 '22 at 02:08
  • I found the mistake I made! While opening the Jupyter_notebook, I chose the notebook which names exactly the same as my python environment, but after checking the kernel by the code >jupyter kernelspec list and compare to the python of Jupyter_notebook, I should have chosen the other notebook so the python would be the same as my kernel. Thank you guys for taking time answering my confusion! Sincerely appreciate! – ian May 22 '22 at 09:33

0 Answers0