1

I have already downloaded NLTK. The next step is to run python and type import nltk and then nltk.download(). When I run IDLE with import nltk, I should see a new window pop up but instead this is the output I receive.

=============== RESTART: /Users/laila/Documents/howboutnow.py ===============
Traceback (most recent call last):
  File "/Users/laila/Documents/howboutnow.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'

For reference, this is the video I've been following to download and use NLTK. https://www.youtube.com/watch?v=FLZvOKSCkxY&list=PLQVvvaa0QuDf2JswnfiGkliBInZnIC4HL I use a 64 bit MacBook Air and have both version 2.7 and 3.4 of Python on my laptop. Any help appreciated!

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
Laila
  • 21
  • 1
  • nltk.py.download() should be nltk.download(). Time 7:08 on the video – Atirag Feb 09 '19 at 15:31
  • This is the output when I changed nltk.py.download() to nltk.download(). ================== RESTART: /Users/laila/Documents/nltk.py ================== Traceback (most recent call last): File "/Users/laila/Documents/nltk.py", line 1, in import nltk File "/Users/laila/Documents/nltk.py", line 3, in nltk.download() AttributeError: module 'nltk' has no attribute 'download' – Laila Feb 09 '19 at 15:42
  • rename your file nltk.py to something else like my_nltk.py and run again. – Atirag Feb 09 '19 at 15:45
  • Output was as follows: ================= RESTART: /Users/laila/Documents/my_nltk.py ================= Traceback (most recent call last): File "/Users/laila/Documents/my_nltk.py", line 1, in import nltk File "/Users/laila/Documents/nltk.py", line 3, in nltk.download() AttributeError: module 'nltk' has no attribute 'download' – Laila Feb 09 '19 at 15:51
  • Delete this file "/Users/laila/Documents/nltk.py" – Atirag Feb 09 '19 at 15:52
  • 1
    import nltk is to import the installed nltk module but since you have a file named nltk.py on the same folder the import is importing this file and that's where the problem happens. You should never name your file the same as a python module – Atirag Feb 09 '19 at 15:54
  • It worked!!!! Thank you so much!! My programming teacher who has been working with Python for 5-6 years couldn't even figure it out. I can't thank you enough, I seriously appreciate it! I've had this problem for 3 weeks now and only now, a wave of relief rushes over me knowing it's solved. Thank you many times over Atirag! – Laila Feb 09 '19 at 16:00
  • Glad I could help :) Also you should get a new teacher ;) – Atirag Feb 09 '19 at 16:03
  • I'll make you my go-to ;) (jokes) – Laila Feb 09 '19 at 16:08

0 Answers0