Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Api' object has no attribute '_Api__auth' #119

Closed
philsturgeon opened this issue Nov 8, 2013 · 16 comments
Closed

'Api' object has no attribute '_Api__auth' #119

philsturgeon opened this issue Nov 8, 2013 · 16 comments

Comments

@philsturgeon
Copy link
Contributor

Not sure why, when or how this started happening, but if I just do self.twitter = twitter.Api() my code has a bad time:

  File "/var/cron/stats/reach.py", line 30, in __init__
    self.twitter = twitter.Api()
  File "/usr/local/lib/python2.7/dist-packages/twitter.py", line 2350, in __init__
    self.SetCredentials(consumer_key, consumer_secret, access_token_key, access_token_secret)
  File "/usr/local/lib/python2.7/dist-packages/twitter.py", line 2382, in SetCredentials
    self._config = self.GetHelpConfiguration()
  File "/usr/local/lib/python2.7/dist-packages/twitter.py", line 2386, in GetHelpConfiguration
    json = self._RequestUrl(url, 'GET')
  File "/usr/local/lib/python2.7/dist-packages/twitter.py", line 4974, in _RequestUrl
    auth=self.__auth,
AttributeError: 'Api' object has no attribute '_Api__auth'

But if I use twitter.Api with named params then it's all good:

        api = twitter.Api(
            consumer_key=self.config['twitter']['consumer_key'],
            consumer_secret=self.config['twitter']['consumer_secret'],
            access_token_key=post['oauth_token'],
            access_token_secret=post['oauth_token_secret']
        )

The first example was taken from your readme, so it should work.

Ideas?

@gersande
Copy link

I have this exact same problem...

@bear
Copy link
Owner

bear commented Nov 21, 2013

That means we suck at documentation :(

The twitter.Api() method has 4 required parameters

On Wed, Nov 20, 2013 at 7:34 PM, Gersande notifications@github.com wrote:

I have this exact same problem...


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-28947747
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@japherwocky
Copy link

Related I think, I've just today picked up this library, and trying to follow the example in the README:

(env)japherwocky@localdev:~/navel$ pip install twitter -U
Downloading/unpacking twitter from https://pypi.python.org/packages/source/t/twitter/twitter-1.10.2.tar.gz#md5=8bff1167b3886c759ee76afa8b52267e
  Downloading twitter-1.10.2.tar.gz
  Running setup.py egg_info for package twitter

Installing collected packages: twitter
  Found existing installation: twitter 1.10.0
    Uninstalling twitter:
      Successfully uninstalled twitter
  Running setup.py install for twitter

    Installing twitter-log script to /home/japherwocky/navel/env/bin
    Installing twitter script to /home/japherwocky/navel/env/bin
    Installing twitterbot script to /home/japherwocky/navel/env/bin
    Installing twitter-follow script to /home/japherwocky/navel/env/bin
    Installing twitter-stream-example script to /home/japherwocky/navel/env/bin
    Installing twitter-archiver script to /home/japherwocky/navel/env/bin
Successfully installed twitter
Cleaning up...
(env)japherwocky@localdev:~/navel$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twitter
>>> twitter.Api()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Api'

So.. not only is it not throwing an error that required params are missing, it seems like that example code is not right at all ?

Awkward, because there's no real clues on how to start working with this in a non-command-line way?

@bear
Copy link
Owner

bear commented Nov 21, 2013

this is another problem - your using the other twitter python lib

ours is installed using:

pip install python-twitter

On Thu, Nov 21, 2013 at 4:07 PM, Japhy Bartlett notifications@github.comwrote:

Related I think, I've just today picked up this library, and trying to
follow the example in the README:

(env)japherwocky@localdev:~/navel$ pip install twitter -U
Downloading/unpacking twitter from https://pypi.python.org/packages/source/t/twitter/twitter-1.10.2.tar.gz#md5=8bff1167b3886c759ee76afa8b52267e
Downloading twitter-1.10.2.tar.gz
Running setup.py egg_info for package twitter

Installing collected packages: twitter
Found existing installation: twitter 1.10.0
Uninstalling twitter:
Successfully uninstalled twitter
Running setup.py install for twitter

Installing twitter-log script to /home/japherwocky/navel/env/bin
Installing twitter script to /home/japherwocky/navel/env/bin
Installing twitterbot script to /home/japherwocky/navel/env/bin
Installing twitter-follow script to /home/japherwocky/navel/env/bin
Installing twitter-stream-example script to /home/japherwocky/navel/env/bin
Installing twitter-archiver script to /home/japherwocky/navel/env/bin

Successfully installed twitter
Cleaning up...
(env)japherwocky@localdev:~/navel$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

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

So.. not only is it not throwing an error that required params are
missing, it seems like that example code is not right at all ?

Awkward, because there's no real clues on how to start working with this
in a non-command-line way?


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-29024504
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@japherwocky
Copy link

Oh! Thank you, many apologies for the noise.

@gersande
Copy link

Thanks very much!

@kureta
Copy link
Contributor

kureta commented Dec 4, 2013

Hi. Can you just delete this line from the README.md file:

api = twitter.Api()

@bear
Copy link
Owner

bear commented Dec 4, 2013

That part is still accurate.

What is happening is way back when there was only two Python Twitter
library, mine and DeWitt's we merged into one and kept the class name
"twitter" but changed the package name to python-twitter (which IIRC was
what DeWitt had)

So that is accurate, people just find our docs online when they are
searching for the other package now.

On Wed, Dec 4, 2013 at 3:56 PM, kureta notifications@github.com wrote:

Hi. Can you just delete this line from the README.md file:

api = twitter.Api()


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-29844586
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@kureta
Copy link
Contributor

kureta commented Dec 4, 2013

so this command
pip install python-twitter
does not install your package. Is that correct?

@bear
Copy link
Owner

bear commented Dec 4, 2013

it does install the package but we are a single .py module library so the
import is "import twitter.py"

which, yes, causes some new folks all kinds of confusion.

What we should do is work hard on v2 and change the name so it matches the
package name.

On Wed, Dec 4, 2013 at 4:18 PM, kureta notifications@github.com wrote:

so this command

pip install python-twitter
does not install your package. Is that correct?


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-29846569
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@kureta
Copy link
Contributor

kureta commented Dec 4, 2013

sorry for taking your time but on a previous comment you have said
"That means we suck at documentation :( The twitter.Api() method has 4 required parameters"
Doesn't that mean this line:
api = twitter.Api()
shouldn't work and this line:
api = twitter.Api(consumer_key='consumer_key',
consumer_secret='consumer_secret',
access_token_key='access_token',
access_token_secret='access_token_secret')
should work?

@bear
Copy link
Owner

bear commented Dec 4, 2013

never worry about asking too many questions, each question is something we
need to get better at...

correct, I do need to change the README to have a more realistic example

  • if you want to edit that on github and submit a PR that is great, if not
    I'll get to it this weekend

On Wed, Dec 4, 2013 at 4:27 PM, kureta notifications@github.com wrote:

sorry for taking your time but on a previous comment you have said

"That means we suck at documentation :( The twitter.Api() method has 4
required parameters"
Doesn't that mean this line:
api = twitter.Api()
shouldn't work and this line:
api = twitter.Api(consumer_key='consumer_key',
consumer_secret='consumer_secret',
access_token_key='access_token',
access_token_secret='access_token_secret')
should work?


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-29847216
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@kureta
Copy link
Contributor

kureta commented Dec 4, 2013

Thanks for your really quick responses. I am just a hobbyist. I don't even know how to submit a PR. I tried to edit the README.md file. Hope I did it right. If so, it is my first actual contribution to an open-source project. Not a big one though :)

@onam
Copy link

onam commented Sep 25, 2014

I am able to post a tweet using python-twitter.
status= api.PostUpdate('I love Python-twitter')
However, when I try:
search = api.GetSearch(term='adventure', lang='en', result_type='recent', count=100, max_id='')
I get the following error:
'module' object has no attribute 'GetSearch'

I do not understand what is going on? Can I get some help?

@uayyappa
Copy link

uayyappa commented Jul 7, 2015

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

@bear
Copy link
Owner

bear commented Jul 7, 2015

Thanks for updating the group with your solution!

On Tue, Jul 7, 2015 at 2:00 AM, u.v.n.r.ayyappaswamy <
notifications@github.com> wrote:

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


Reply to this email directly or view it on GitHub
#119 (comment)
.

Bear

bear@andyet.com (email)
bear42@gmail.com (email)
bear@bear.im (xmpp, email)
http://bear.im

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants