Can't import nltk even though it is installed on my machine

Viewed 44

When I open a jupyter notebook and try to import NLTK it errors. I can import other packages but I cannot import NLTK

I'll add a screenshot below to illustrate all of this but

  • I installed nltk with pip3 install nltk on my mac
  • I can run pip show nltk to see the successful installation
  • I can't import nltk in jupyter notebooks or by running it in the python terminal
  • I am not using any environments or conda environments
  • I am using python 3.9.6

enter image description here

2 Answers
import nltk
nltk.download()

your python installations and your ipython are separate.

Hello,

if you run Mac/Unix

Install NLTK: run pip install --user -U nltk

Install Numpy (optional): run pip install --user -U numpy

Test installation: run python then type import nltk

For older versions of Python it might be necessary to install setuptools (see https://pypi.python.org/pypi/setuptools) and to install pip (sudo easy_install pip).

Windows

These instructions assume that you do not already have Python installed on your machine.

32-bit binary installation Install Python 3.8: https://www.python.org/downloads/ (avoid the 64-bit versions)

Install Numpy (optional): https://www.scipy.org/scipylib/download.html

Install NLTK: https://pypi.python.org/pypi/nltk

Test installation: Start>Python38, then type import nltk

And if it doesnt work, install nltk using Conda By :

conda install -c anaconda nltk

For more info check : https://www.nltk.org/install.html

Related