2013-06-01 84 views
0

我安裝的是Twitter的包裝爲Python安裝並運行它,但得到這個錯誤NameError:全球名「推特」沒有定義

Traceback (most recent call last): 
    File "/home/siddhartha/workspace/trouveunappart/src/test.py", line 35, in <module> 
    sid() 
    File "/home/siddhartha/workspace/trouveunappart/src/test.py", line 12, in sid 
    t = Twitter(
NameError: global name 'Twitter' is not defined 

代碼:

from twitter import * 



CONSUMER_KEY = '' 
CONSUMER_SECRET = '' 
OAUTH_TOKEN = '' 
OAUTH_SECRET = '' 


t = Twitter(
       auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET, 
       CONSUMER_KEY, CONSUMER_SECRET) 
      ) 




since_ID = -1 
max_ID = 0 

while(since_ID != max_ID): 
    search = t.search.tweets(q = k, count = 100, since_id = max_ID) 

    print len(search['statuses']) 
    if len(search['statuses']) == 0: 
     print 'end' 
     break 


    since_ID = search['search_metadata']['since_id_str'] 
    max_ID = search['search_metadata']['max_id_str'] 
+0

_我們在談論哪一個twitter圖書館? – kirelagin

+0

@kirelagin http://mike.verdone.ca/twitter/#development – codious

+0

這是否值得-1?我認爲它很難弄清楚爲什麼這不起作用 – codious

回答

1

只是一個猜測。是否有可能安裝了另一個Twitter庫?我的意思是,import twitter適合你,但不存在twitter.Twitter這應該在那裏,如果你真的使用Python嘰嘰喳喳工具

例如,python-twitter沒有twitter.Twitter,但twitter.Api這不蟒蛇Twitter的工具存在。似乎你有python-twitter,而不是python twitter工具

+0

fixed!thanks :) – codious

相關問題