api = twitter.Api() AttributeError: 'module' object has no attribute 'Api

后端 未结 7 1128
借酒劲吻你
借酒劲吻你 2020-12-17 10:14

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. Run

相关标签:
7条回答
  • 2020-12-17 10:35

    Use module python-twitter instead of twitter

    $ pip install python-twitter
    

    Reference : https://python-twitter.readthedocs.io/en/latest/installation.html

    For Modules Documentation : https://python-twitter.readthedocs.io/en/latest/twitter.html#modules-documentation

    0 讨论(0)
  • 2020-12-17 10:40

    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()
    
    0 讨论(0)
  • 2020-12-17 10:42

    i found solution to this problem in following site

    [http://himanen.info/solved-attributeerror-module-object-has-no-attribute-api/][1]

    There are two Python libraries conflicting: twitter library and python-twitter library. The solution was quite straightforward:

    pip uninstall twitter
    

    Then I just made it sure that python-twitter was certainly installed:

    pip install python-twitter
    

    Thank you himanen it worked for me

    0 讨论(0)
  • 2020-12-17 10:46

    i found solution to this problem in following site

    [http://himanen.info/solved-attributeerror-module-object-has-no-attribute-api/][1]

    There are two Python libraries conflicting: twitter library and python-twitter library. The solution was quite straightforward:

    pip uninstall twitter Then I just made it sure that python-twitter was certainly installed:

    pip install python-twitter thank you himanen..it really works

    0 讨论(0)
  • 2020-12-17 10:47

    If you are using the python-twitter wrapper. during installation process it must have created an eggfile with the name twitter.py.egg rename it by some other name like help.py.egg it will work for you.

    0 讨论(0)
  • 2020-12-17 10:53

    I got the same error because my python file was called twitter.py. It contained:

    import twitter
    api = twitter.Api (consumer_key=...
    

    I renamed the file to twitterdata.py, removed twitter.pyc and then it worked.

    0 讨论(0)
提交回复
热议问题