Skip to content Skip to sidebar Skip to footer

How To Fix Importerror: Cannot Import Name 'format_exception_only' In Python

I am using pycharm community version for python 3.6.1 as I'm beginner when i try to run simple tokenize program - import nltk from nltk.tokenize import word_tokenize word_tokeniz

Solution 1:

File "E:\test\token.py", line 2, in from nltk.tokenize import word_tokenize

There happen to be another script with the same name Python is looking for. Python got confused about the script from package and your own script because it start searching from the folder where you are. So just change your own script to another name.

Solution 2:

Go to command prompt(not necessarily command prompt. You can do it from IDLE also). Do an nltk.download() in the python interpreter and then download all-corpora and book. After you do this, run your program. It should work.

Post a Comment for "How To Fix Importerror: Cannot Import Name 'format_exception_only' In Python"