jason
jason

Reputation: 5491

'module' object has no attribute 'Twitter'

I am trying to follow the example on page 5 of the book: Mining the Social Web, from O'Reilly. I am coming across the following error:

>>> import twitter
>>> twitter_api = twitter.Twitter(domain="api.twitter.com", api_version='1')
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'Twitter'

What might be going on?

Upvotes: 4

Views: 2916

Answers (2)

Mu Mind
Mu Mind

Reputation: 11214

Check the value of twitter.__file__ (after you've imported twitter). My guess is either you somehow got a broken version of twitter, or you've created a file called twitter.py in the same directory you're running from that's blocking the installed module from loading.

If twitter.__file__ looks good (points to where your installed modules should be instead of the local dir), try easy_install -U twitter to reinstall it.

Upvotes: 4

Imran
Imran

Reputation: 91119

Works for me. I installed twitter through easy_install, which installed the latest version (1.6.1). dir(twitter) also lists Twitter here.

You could remove the twitter package from site-packages and try reinstalling again.

Upvotes: 4

Related Questions