0

I am trying this in my PyDev setup on eclipse:

from sqlalchemy.engine import create_engine

This gives me following error:

Traceback (most recent call last):
  File "/Users/<username>/Documents/workspace/You/src/Ormtest.py", line 7, in <module>
    import sqlalchemy
  File "build/bdist.macosx-10.8-intel/egg/sqlalchemy/__init__.py", line 7, in <module>
    # For license information, see LICENSE.TXT
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 39, in <module>
    import tokenize
  File "/Library/Python/2.7/site-packages/nltk/tokenize/__init__.py", line 50, in <module>
    from nltk.data              import load
  File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 106, in <module>
    from decorators import decorator, memoize
  File "/Library/Python/2.7/site-packages/nltk/decorators.py", line 176, in <module>
    @decorator
  File "/Library/Python/2.7/site-packages/nltk/decorators.py", line 154, in decorator
    if inspect.isclass(caller):
AttributeError: 'module' object has no attribute 'isclass'

This works fine on the interactive console. Also Eclipse does not give me any error/warning on import. Any idea what am I missing here?

2
  • that exception is occurring deep within nltk, the natural language toolkit, which has nothing to do with SQLAlchemy and is not a dependency, so it seems like PyDev is injecting some weird thing in there. This looks like some kind of bug in PyDev, I'd report it to them. Commented May 8, 2013 at 19:25
  • Or it might be related just to NLTK by itself, they have a package named "tokenize" that's getting mistaken for the Python "tokenize" module. Seems weird. Commented May 8, 2013 at 19:28

1 Answer 1

2

Try doing the following to diagnose it: In the line that gives the error do:

import sys
print('\n'.join(sorted(sys.path))) #to know which pythonpath you're using

My guess is that you added "/Library/Python/2.7/site-packages/nltk" to your PYTHONPATH (whereas you probably should only add "/Library/Python/2.7/site-packages")

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

1 Comment

This seems to have solved the problem. Removing nltk and adding just site-packages have resolved the issue for now. Thanks for this. I will get back to you in case any problem arises again :)

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.