user1626276
user1626276

Reputation:

twitter Api giving error using python

hi i am new to python and i got this error but i have installed twitter but it's giving this error

import twitter
api=twitter.Api()
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
api=twitter.Api()
AttributeError:'module' object has no attribute 'Api'

I don't know about this error as i have almost every package related to twitter

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    api = twitter.Api()
AttributeError: 'module' object has no attribute 'Api'

when i give this command python setup.py install_data it give error like this running install_data

Traceback (most recent call last) :
file "setup.py" ,line 47 , <module>
""" ,
File "C:\python26\lib\distutils\core.py" ,line 152 , in setup
dist.run_commands()
File "C:\python26\lib\distutils\dist.py" ,line 975 , in run_commands
self.run_command(cmd)
File "C:\python26\lib\distutils\dist.py" ,line 995 , in run_commands
command_obj.run
File "C:\python26\lib\distutils\command\install_data.py" , line 44 in run
For f in self.data_files

Upvotes: 1

Views: 5449

Answers (5)

user1626276
user1626276

Reputation:

Your mixed with libraries actually the problem is that your are reading library of python_twitter and installed twitter.You need select the correct documentation.This is documentation error nothing else.You installed correct library.

Upvotes: 1

thebjorn
thebjorn

Reputation: 27360

You've installed the wrong twitter library. I'm guessing you've done

pip install twitter

you should uninstall that library:

pip uninstall twitter

and install the correct(*) one

pip install python_twitter

(*) by correct I mean the one you're reading the documentation to :-)

Upvotes: 0

Brenden Brown
Brenden Brown

Reputation: 3235

Where did you install the python twitter module from? I used http://code.google.com/p/python-twitter/source/browse/twitter.py, and it has an Api class.

>>> import twitter
>>> api = twitter.Api()

Upvotes: 0

Lenna
Lenna

Reputation: 1465

The error message "'module' object has no attribute 'Api'" means what it says: Python can't find anything named 'Api' inside the imported module 'twitter'.

Try dir(twitter) after the import statement. dir() will show what Python finds inside the object. If dir(twitter) shows an object called 'twitter', you may have to do something like from twitter import twitter.

Upvotes: 0

chheplo
chheplo

Reputation: 211

can you reinstall using,

sudo pip install twitter

or

sudo easy_install twitter

The old versions did not required OAuth but new one does. The documentation of the latest version requires these to initiate the API

>>> api = twitter.Api(consumer_key='consumer_key',

    consumer_secret='consumer_secret', access_token_key='access_token', access_token_secret='access_token_secret') 

Upvotes: 1

Related Questions