Python Forum

Full Version: NLTK Download Attribute error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all, I'm having a problem downloading NLTK. This is my first time downloading a module and I keep getting an error. I have been following https://www.youtube.com/watch?v=FLZvOKSCkxY to download NLTK on my MacBook Air. I successfully installed NLTK and I know that because when I type pip install nltk, this is the output:
Last login: Sat Jan 26 09:10:45 on ttys000
Lailas-Air:~ laila$ pip install nltk
Requirement already satisfied: nltk in /Library/Python/2.7/site-packages (3.4)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from nltk) (1.4.1)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages (from nltk) (3.4.0.3)
Lailas-Air:~ laila$ 
The next step in the video was to install nltk using a file I created under idle. I created the new file and typed import nltk, but I received the following output when I ran it(this showed up in idle, not the file):
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> 
================ RESTART: /Users/laila/Documents/nltk now.py ================
Traceback (most recent call last):
  File "/Users/laila/Documents/nltk now.py", line 1, in <module>
    import nltk
  File "/Users/laila/Documents/nltk.py", line 3, in <module>
    nltk.py.download()
AttributeError: module 'nltk' has no attribute 'py'
>>>
I was supposed to receive the same output the guy in the video did at 7:03.
go to the NLTK install page and follow instructions there: https://www.nltk.org/install.html
It's simple, then load corpora:
  1. open python interpreter from command line
  2. >>> import nltk
  3. >>> nltk.download()
choose and install all or some corpora