API = twitter.Api()AttributeError的:'模块'对象有没有属性'阿比 [英] api = twitter.Api() AttributeError: 'module' object has no attribute 'Api

查看:415
本文介绍了API = twitter.Api()AttributeError的:'模块'对象有没有属性'阿比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想写一个简单提一下采集开始使用Twitter的API。不论如何初始化API时,我已经experienceing一些困难。
在ArchLinux的我通过安装的easy_install运行叽叽喳喳python2,建立从源头,并通过PIP安装。这一切都似乎是工作。

 小狗::〜为/ dev / kritter»python2
Python的2.7.2(默认情况下,2012年1月31日,13时26分35秒)
[GCC 4.6.2 20120120($ P $租赁前)linux2的上
键入help,版权,信用或许可的详细信息。
>>>进口叽叽喳喳
>>> API = twitter.Api()
回溯(最近通话最后一个):
  文件<&标准输入GT;,1号线,上述<&模块GT;
AttributeError的:'模块'对象有没有属性'阿比

不论如何为Twitter上的pydoc是存在的。我不知道我在做什么错。我希望你能帮助

更新:
我试着用 twitter.api()而不是 twitter.Api()并得到了以下错误:
    回溯(最近通话最后一个):
    文件main.py,8号线,在
    API = twitter.api()
    类型错误:'模块'对象不是可调用

其他信息:

 >>>打印目录(微博)
['NOAUTH','OAuth的','微','TwitterError','TwitterHTTPError','TwitterResponse','TwitterStream','UserPassAuth','__all__','__builtins__','__doc__','__file__',' __name__','__PACKAGE__','__path__,API,权威性,OAuth的','read_token_file','流','twitter_globals','write_token_file']
>>>打印叽叽喳喳.__ path__
['/usr/lib/python2.7/site-packages/twitter-1.7.2-py2.7.egg/twitter']


解决方案

我想你已经安装了一个Twitter的包,看看另一个文档。即:蟒蛇-1.7.2从 https://github.com/sixohsix/twitter 项目,而你正在寻找在 HTTP://$c$c.google.com/p/python-twitter/ 文档。两者之间的不匹配:)

因此​​,对于一个你已经安装了,如果你检查源$ C ​​$ C,A的流示例是可用的,并且在pydoc其它各种实例

 从Twitter进口微博
  #...
  Twitter的微博=(
      AUTH =的OAuth(令牌,token_key,con_secret,con_secret_key)))  #获取公开时间表
  twitter.statuses.public_timeline()

I have been trying to write a simple mention grabber to get started with the twitter Api. Howsoever I've been experienceing some difficulties when initializing the Api. Running python2 on archlinux I installed twitter via easy_install, built it from source and installed it via pip. None of this seems to be working.

zergling :: ~/dev/kritter » python2
Python 2.7.2 (default, Jan 31 2012, 13:26:35) 
[GCC 4.6.2 20120120 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twitter
>>> api = twitter.Api()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Api'

Howsoever the pydoc for twitter is there. I have no clue what I'm doing wrong. I hope you can help

UPDATE: I tried using twitter.api() instead of twitter.Api() and got the following error: Traceback (most recent call last): File "main.py", line 8, in api = twitter.api() TypeError: 'module' object is not callable

Additional Informations:

>>> print dir(twitter)
['NoAuth', 'OAuth', 'Twitter', 'TwitterError', 'TwitterHTTPError', 'TwitterResponse',  'TwitterStream', 'UserPassAuth', '__all__', '__builtins__', '__doc__', '__file__',  '__name__', '__package__', '__path__', 'api', 'auth', 'oauth', 'read_token_file', 'stream', 'twitter_globals', 'write_token_file']
>>> print twitter.__path__
['/usr/lib/python2.7/site-packages/twitter-1.7.2-py2.7.egg/twitter']

解决方案

I think you've installed one twitter package, and look at another documentation. Ie: python-1.7.2 is the project from https://github.com/sixohsix/twitter, while you're looking at the http://code.google.com/p/python-twitter/ documentation. No match between both :)

So for the one you've installed, if you check the source code, a stream example is available, and other various examples in the pydoc:

  from twitter import Twitter
  # ...
  twitter = Twitter(
      auth=OAuth(token, token_key, con_secret, con_secret_key)))

  # Get the public timeline
  twitter.statuses.public_timeline()

这篇关于API = twitter.Api()AttributeError的:'模块'对象有没有属性'阿比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆