Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python -m textblob.download_corpora is giving error on Python 2 #315

pratyushmittal opened this issue Apr 13, 2020 · 4 comments


Copy link

It seems nltk library released version 3.5 today. It is Python 3 only. This breaks textblob on Python 2.

I was able to fix the errors by adding the static nltk==3.4.5 in requirements.

Copy link

Yep, same error on Python 2.7.17, when trying to install corpora

python -m textblob.download_corpora


Traceback (most recent call last):
  File "/usr/local/lib/python2.7/", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/usr/local/lib/python2.7/", line 102, in _get_module_details
    loader = get_loader(mod_name)
  File "/usr/local/lib/python2.7/", line 462, in get_loader
    return find_loader(fullname)
  File "/usr/local/lib/python2.7/", line 472, in find_loader
    for importer in iter_importers(fullname):
  File "/usr/local/lib/python2.7/", line 428, in iter_importers
  File "/usr/local/lib/python2.7/site-packages/textblob/", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python2.7/site-packages/textblob/", line 28, in <module>
    import nltk
  File "/usr/local/lib/python2.7/site-packages/nltk/", line 128, in <module>
    from nltk.collocations import *
  File "/usr/local/lib/python2.7/site-packages/nltk/", line 35, in <module>
    from nltk.probability import FreqDist
  File "/usr/local/lib/python2.7/site-packages/nltk/", line 333
    print("%*s" % (width, samples[i]), end=" ")
SyntaxError: invalid syntax

Fixed by adding the static nltk==3.4.5 in requirements.txt

Copy link

Romiko commented Apr 26, 2020

Yup, Same error. Does this mean I need to manually download this library and compile it from source?

Copy link

sloria commented Apr 26, 2020

@Romiko You need to pin to nltk==3.4.5 as suggested above.

Copy link

sloria commented Apr 26, 2020

#318 pins the NLTK version based on Python version, so that a compatible version of NLTK automatically gets installed.

For now, though, you'll just need to pin NLTK manually.

@sloria sloria closed this as completed Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

4 participants