I am new to the Twitter API and python-twitter. I am trying to run the simple program below:
import twitter
api = twitter.Api()
user = 'GoldmanSachs'
statuses = api.GetUserTimeline(screen_name=user)
for s in statuses:
print s
When I run the program in the Python Shell I get the expected output below.
{"created_at": "Mon Jan 28 22:21:14 +0000 2013", "favorited": false, "id": 296020134164836353, "retweet_count": 2, "retweeted": false, "source": "web", "text": "ICYMI: WSJ's Davos Live Blog spoke to FX de Mallmann about European corporations raising funds in the bond market. http://t.co/hCLGBOOy", ....}
However, when I try to save the program and then run it I get an AttributeError:
Traceback (most recent call last):
File "\twitter.py", line 1, in <module>
import twitter
File "\twitter.py", line 6, in <module>
api = twitter.Api()
AttributeError: 'module' object has no attribute 'Api'
Any thoughts on why this is happening would be greatly appreciated.
Most likely you named your program twitter.py
and it's shadowing python-twitter
. Rename your script.