4
votes

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?

2
dir a dir(twitter) and see if Twitter shows up - amccormack
no its not...I am wondering if the api changed and the book is outdated..... - jason
If you are interested in working with twitter's api i'd recommend tweepy. It's very good and quite easy to use: github.com/joshthecoder/tweepy - zeekay

2 Answers

4
votes

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.

4
votes

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.