Error when executing TwitterSearch in Python -


i attempting use twittersearch (https://github.com/ckoepp/twittersearch) import tweets csv analysis. however, getting following error message when executing python script:

from .twittersearchexception import twittersearchexception valueerror: attempted relative import in non-package 

here code:

from twittersearch import * twittersearchexception import * import csv  def get_tweets(query, max_tweets):     query = raw_input ("search for:")     max_tweets = 2000     # takes search term (query) , max number of tweets find     # gets content twitter , writes csv bearing name of query      = 0     search = query      open(search+'.csv', 'wb') outf:         writer = csv.writer(outf)         writer.writerow(['user','time','tweet','latitude','longitude'])         try:             tso = twittersearchorder()             tso.set_keywords([search])             tso.set_language('en') # english tweets              ts = twittersearch(                 consumer_key = '',                 consumer_secret = '',                 access_token = '',                 access_token_secret = ''             )              tweet in ts.search_tweets_iterable(tso):                 lat = none                 long = none                 time = tweet['created_at'] # utc time when tweet created.                 user = tweet['user']['screen_name']                 tweet_text = tweet['text'].strip().encode('ascii', 'ignore')                 tweet_text = ''.join(tweet_text.splitlines())                 print i,time,                 if tweet['geo'] != none , tweet['geo']['coordinates'][0] != 0.0: # avoiding bad values                     lat = tweet['geo']['coordinates'][0]                     long = tweet['geo']['coordinates'][1]                     print('@%s: %s' % (user, tweet_text)), lat, long                 else:                     print('@%s: %s' % (user, tweet_text))                  writer.writerow([user, time, tweet_text, lat, long])                 += 1                 if > max:                     return()          except twittersearchexception e:             print(e) 

thanks help!

try more specific import twittersearchexception line, instead of *.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -