python程序系统找不到指定文件_使用Sublim运行Python时出现错误“系统找不到指定的文件”...

我试着运行我的twitter bot代码,得到了以下错误:[Error 2] The system cannot find the file specified

[cmd: [u'python', u'-u', u'C:\Users\humza\Desktop\Simple-Python-TwitterBot-master\run.py']]

[dir: C:\Users\humza\Desktop\Simple-Python-TwitterBot-master]

[path: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\RailsInstaller\Git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\Skype\Phone\;C:\Users\humza\AppData\Local\Programs\Common\Microsoft]

[Finished]

这是我的代码:import tweepy

from tweepy.auth import OAuthHandler

from tweepy.streaming import StreamListener, Stream

ckey = ""

csecret = ""

atoken = ""

asecret = ""

auths = OAuthHandler(ckey, csecret)

auths.set_access_token(atoken, asecret)

api = tweepy.API(auths)

class listener(StreamListener):

def on_data(self, raw_data):

try:

tweet_text = raw_data.lower().split('"text":"') [1].split('","source":"')[0].replace(",", "")

screen_name = raw_data.lower().split('"screen_name":"')[1].split('","location"')[0].replace(",", "")

tweet_cid = raw_data.split('"id":')[1].split('"id_str":')[0].replace(",", "")

accs = [] # banned account screen name goes in here

words = [] # banned words goes in here

if not any(acc in screen_name.lower() for acc in accs):

if not any(word in tweet_text.lower() for word in words):

# call what u want to do here

#fav(tweet_cid)

#retweet(tweet_cid)

#syntax need to be fixed here

return True

except Exception as e:

print(str(e)) # prints the error msg, if u dont want it comment it out

pass

def on_error(self, status_code):

try:

print( "error" + status_code)

except Exception as e:

print(str(e))

pass

def create_tweet():

"""Kent is Great!"""

# Replace this with your code!

text = ""

return text

def retweet(tweet_cid):

try:

api.retweet(tweet_cid)

except Exception as e:

print(str(e))

pass

def fav(tweet_cid):

try:

api.create_favorite(tweet_cid)

except Exception as e:

print(str(e))

pass

def unfav(tweet_cid):

try:

api.destroy_favorite(tweet_cid)

except Exception as e:

print(str(e))

pass

def tweet(myinput):

try:

api.update_status(status=myinput)

except Exception as e:

print(str(e))

pass

def tweet(text):

"""Send out the text as a tweet."""

# Twitter authentication

auth = tweepy.OAuthHandler(C_KEY, C_SECRET)

auth.set_access_token(A_TOKEN, A_TOKEN_SECRET)

api = tweepy.API(auth)

# Send the tweet and log success or failure

try:

api.update_status(text)

except tweepy.error.TweepError as e:

log(e.message)

else:

log("Tweeted: " + text)

track_words = ["kent"]

follow_acc = ['946886204'] # all username converted to user ids

try:

twt = Stream(auths, listener())

twt.filter(track= track_words , follow = follow_acc)

except Exception as e:

print(str(e))

pass

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值