开发者

'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 = twit开发者_如何学编程ter.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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜