Twitter-Modul von python - 'Modul' - Objekt hat kein Attribut Oauth

Im Versuch, Folgen Sie diesem einfachen Beispiel hier.

Code

import twitter

# XXX: Go to http://dev.twitter.com/apps/new to create an app and get values
# for these credentials, which you'll need to provide in place of these
# empty string values that are defined as placeholders.
# See https://dev.twitter.com/docs/auth/oauth for more information 
# on Twitter's OAuth implementation.

CONSUMER_KEY = ''
CONSUMER_SECRET =''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''

auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
                           CONSUMER_KEY, CONSUMER_SECRET)

twitter_api = twitter.Twitter(auth=auth)

# Nothing to see by displaying twitter_api except that it's now a
# defined variable

print twitter_api

Aber läuft das Beispiel wirft die folgenden Fehler.

vagrant@lucid32:~$ python twitter.py
Traceback (most recent call last):
  File "twitter.py", line 1, in <module>
    import twitter
  File "/home/vagrant/twitter.py", line 14, in <module>
    auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
AttributeError: 'module' object has no attribute 'oauth'

Jede mögliche Hilfe würde geschätzt.

  • Ich fand, dass twitter.API hat bei mir auch nach der Installation von twitter-Paket und nicht python-twitter
InformationsquelleAutor seeker | 2014-01-07
Schreibe einen Kommentar