2

I have Python 2.6.6 installed

I downloaded the textblob package from Here

I installed the package using the following command

python setup.py install

Inside my site-packages I can see the following egg

textblob-0.11.1-py2.6.egg

However when I am importing the package, it gives me the following error

> from textblob import TextBlob
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/textblob-0.11.1-py2.6.egg/textblob/__init__.py", line 9, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/lib/python2.6/site-packages/textblob-0.11.1-py2.6.egg/textblob/blob.py", line 28, in <module>
    import nltk
  File "/usr/lib/python2.6/site-packages/nltk-3.2.1-py2.6.egg/nltk/__init__.py", line 114, in <module>
    from nltk.collocations import *
  File "/usr/lib/python2.6/site-packages/nltk-3.2.1-py2.6.egg/nltk/collocations.py", line 38, in <module>
    from nltk.util import ngrams
  File "/usr/lib/python2.6/site-packages/nltk-3.2.1-py2.6.egg/nltk/util.py", line 1361
    d = {k: _default_to_regular(v) for k, v in d.items()}
                                 ^
SyntaxError: invalid syntax

Is there anything missing here?

UPDATE 1:

I installed successfully textblob 0.8.4

While installing NLTK 2.0.5, I am getting following error

command:

python setup.py install

Error:

`Installed /usr/lib/python2.6/site-packages/distribute-0.6.21-py2.6.egg
Traceback (most recent call last):
  File "setup.py", line 69, in <module>
    test_suite = 'nltk.test.simple',
  File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "build/bdist.linux-x86_64/egg/setuptools/command/install.py", line 73, in run
  File "build/bdist.linux-x86_64/egg/setuptools/command/install.py", line 101, in do_egg_install
  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 345, in run

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 565, in easy_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 617, in install_item

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 664, in process_distribution

TypeError: __init__() takes exactly 2 arguments (4 given)
`
3
  • 1
    Did you install nltk separately? Where did you install it from? Commented Dec 20, 2016 at 7:15
  • yes I installed nltk 3.2.1 but now I have deleted it. I am installing 2.0.5 but facing issues in it Commented Dec 20, 2016 at 7:19
  • 1
    See my answer. You also need to downgrade TextBlob. Commented Dec 20, 2016 at 7:21

1 Answer 1

3

nltk-3.2.1 doesn't support Python 2.6 (the SyntaxError is due to the fact that dictionary comprehension was not yet introduced to Python until 2.7). Either upgrading your Python to 2.7 or downgrading nltk to 2.0.5:

pip install nltk==2.0.5

Edit: After researched TextBlob's setup.py and CHANGELOG.rst files, it turns out you probably also need to downgrade TextBlob to 0.8.4 to avoid the dependency of nltk>=3.0, if you decided not to upgrade your Python.

Edit 2: To solve the setuptools error, use python distribute_setup.py instead.

Edit 3: You don't need to install nltk if you installed TextBlob <= 0.8.4. Because it contains a vendorized version of nltk.

Sign up to request clarification or add additional context in comments.

6 Comments

I think you're right, but it seems odd that there is a file called nI ltk-3.2.1-py2.6.egg if that NLTK version doesn't support that Python version.
I can't upgrade python
@Hardik then downgrade both nltk and textblob.
installed textblob 0.8.4, downloaded and unziped tar for nltk 2.0.5, then tried installing nltk like this python setup.py install it gives error
@Hardik: it's a new problem. Try python distribute_setup.py. You should upgrade your toolchain someday. The package distribute is deprecated for years.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.