Monday 15 April 2013

Python Twitter: name Twitter is not defined -


I have installed the Python Twitter Library of Sixohsix () and tried to connect to Twitter, but this is not work Does. This is my code: / code / # /! = '...' t = Twitter Get your "home" timeline t.statuses.home_timeline ()

I get an error message:

  traceback (most recent call end): File "./twitter.py", line 3, & lt; Module & gt; From twitter import * file to "/home/XXX/twitter.py", line 11, in & lt; Module & gt; T = Twitter (auth = OAuth (OAUTH_TOKEN, OAUTH_TOKEN, CONSUMER_KEY, CONSUMER_SECRET)) Name: ERROR: The name 'Twitter' is not defined   

I do not know why this error occurs even I Tried

  t = twitter.Twitter (...)   

But this does not work either. I get some posts on stack overflow, but Not all solutions work.

With your traceback, I see that your file name is twitter.py Is:

  in the file "/home/XXX/twitter.py", line 11, in & lt; Module & gt;   

For this reason, Twitter is attempting to import the contents of the line from the script by itself, rather than the library called twitter < / Code>, because the current directory is generally preferred over shared libraries.

Rename your script to the name of the library that you are trying to use (like my_twitter Py ), and things will work.

No comments:

Post a Comment