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

Closed
pratyushmittal opened this issue Apr 13, 2020 · 4 comments
Closed

Comments

@pratyushmittal
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.

@malakhovks
Copy link

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

python -m textblob.download_corpora

Error:

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

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

@Romiko
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?

@sloria
Copy link
Owner

sloria commented Apr 26, 2020

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

@sloria
Copy link
Owner

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants