Nltk: AttributeError: module 'nltk' has no attribute 'download

Created on 18 Feb 2018  ·  16Comments  ·  Source: nltk/nltk

#code 

import nltk
nltk.download()
Traceback (most recent call last):
  File "nltk.py", line 2, in <module>
    import nltk
  File "/Users/antonionogueras/Desktop/NLTK/nltk.py", line 10, in <module>
    nltk.download()
AttributeError: module 'nltk' has no attribute 'download'

Specs:
Mac, High Sierra, Python 3.6

resolved

Most helpful comment

Please rename your file from nltk.py to something else, e.g. my_nltk_script.py. Then rerun the script. Please see

Also, normally you shouldn't be downloading the NLTK data downloads in a script, unless it's an interactive jupyter notebook or interactive interpreter.

All 16 comments

Try putting the name of the model as a parameter of the download() function. e.g.

import nltk
nltk.download('punkt')

@somnathrakshit I have done so by adding 'popular' and 'all', but receive the same error.

'all' and 'popular' will work in an interactive console. Are you trying that or running from a .py script?

@somnathrakshit Yes. I also tried nltk.download('punkt') as you suggested and got the same error.

Can you try it out from an interactive console instead of a .py script? It worked for me.

Please rename your file from nltk.py to something else, e.g. my_nltk_script.py. Then rerun the script. Please see

Also, normally you shouldn't be downloading the NLTK data downloads in a script, unless it's an interactive jupyter notebook or interactive interpreter.

@2hands10fingers did changing your script filename resolve the issue?

@alvations While it did bring up the GUI as intended, I have run into an SSL error which has rendered my ability to interact with the GUI. This is my error.

[SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed(ssl.c:749)

Are you using Python3.6? If so, it looks like ~an upstream bug from CPython~ similar to this issue: https://bugs.python.org/issue28150

See

TL;DR

/Applications/Python 3.6/Install Certificates.command

sudo /Applications/Python\ 3.6/Install\ Certificates.command

Did the trick! I was definitely using Python 3.6. Thank you!

This worked for me.
At first, I had saved a file named nltk.py and in that file, I had written those 2 lines.
Go to C:\Users\User\AppData\Local\Programs\Python\Python36\
In here, delete that nltk.py file.

Now, re-run those 2 lines from the cmd prompt and it'll work.

It still isn't working for me I have tried all of the above ones and yet I still get
"module 'nltk' has no attribute 'internals' "

@2hands10fingers the same problem was with me,i uninstall nltk the reinstall it again then again run those line of code.
1.pip uninstall nltk
2.pip install nltk
3.again run those lines import nltk nltk.download()
4.run it ,it will execute errorfree.

Your terminal Python installation and your ipython install are separate.
What does import sys; print(sys.path) produce in either?

I named my python script nltk.py and that was causing the error. Therefore, I changed it to a different filename and voila it started working!

This worked for me.
At first, I had saved a file named nltk.py and in that file, I had written those 2 lines.
Go to C:\Users\User\AppData\Local\Programs\Python\Python36
In here, delete that nltk.py file.

Now, re-run those 2 lines from the cmd prompt and it'll work.

This solved the issue for me, I am running Python 3.8 on windows 10

Was this page helpful?
0 / 5 - 0 ratings