Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import NLTK : no module NLTK corpus

Tags:

macos

nltk

I have installed NLTK. Here's an image of the installation log.

enter image description here

When i use import nltk i get an error:

"No module named NLTK.corpus"

Here is a screenshot.

enter image description here

What could be the cause?

like image 748
manisha Avatar asked Nov 27 '22 20:11

manisha


2 Answers

I think I had the same problem. So, downloading all the packages at once (since question didn't specify).

Start python and then import the packages, exit python and upgrade nltk. Modify the 'all' to download a specific corpus. Took me awhile to complete the 'all' download, I separately downloaded framenet_v15 and restarted the 'all' after. Upgrade nltk when the download is complete.

$ python
>>>import nltk
>>>nltk.download('all')

exit python

$ pip install --upgrade nltk
like image 131
Derek_P Avatar answered Dec 12 '22 10:12

Derek_P


To fix this, you should rename your file to something else, say nltkXXX.py. Also make sure to remove "nltk.pyc" from your directory if it exists, since this will also be loaded (it's the byte compiled version of your code). After that, it should work fine.

like image 45
Edward Avatar answered Dec 12 '22 10:12

Edward