[Solved] Python newb MacOS in IDLE and PyCharm ModuleNotFoundError: No module named ‘nltk’

I am trying to import the natural language process library nltk , following instructions from nltk.org
I have done a successful install (see output below)

But when I run import nltk in IDLE, I get ModuleNotFoundError: No module named ‘nltk’

I would try using path, but I don’t know where the NLTK software was installed. I have tried whereis and which nltk.* and neither command finds anything.

Garys-MacBook-Pro:Documents garynackenson$ sudo pip install -U nltk
The directory ‘/Users/garynackenson/Library/Caches/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.

The directory ‘/Users/garynackenson/Library/Caches/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Collecting nltk
Downloading https://files.pythonhosted.org/packages/50/09/3b1755d528ad9156ee7243d52aa5cd2b809ef053a0f31b53d92853dd653a/nltk-3.3.0.zip (1.4MB)
100% |????????????????????????????????| 1.4MB 5.5MB/s
Requirement already satisfied, skipping upgrade: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from nltk) (1.4.1)
Installing collected packages: nltk
Running setup.py install for nltk … done
Successfully installed nltk-3.3

Solution #1:

Can you try below and see if it solves it since PyCharm creates its own environment. so one way of solving it would be to do the following. In PyCharm click on:

File/Settings/Project:project-Name/Project Interpreter

Click on the plus sign (assuming you’re using the latest version) and find the package you’re looking for.

Respondent: Nasrin
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.