Python &引用;bash:*.py:command not found";“当我跑的时候”;heroku run worker“;
我正在尝试使用python、tweepy和heroku制作一个twitter机器人, 这是我的python脚本Python &引用;bash:*.py:command not found";“当我跑的时候”;heroku run worker“;,python,heroku,tweepy,Python,Heroku,Tweepy,我正在尝试使用python、tweepy和heroku制作一个twitter机器人, 这是我的python脚本 import tweepy, codecs, time CONSUMER_KEY = '***************' CONSUMER_SECRET = '*****************************' ACCESS_KEY = '******************************' ACCESS_SECRET = '*******************
import tweepy, codecs, time
CONSUMER_KEY = '***************'
CONSUMER_SECRET = '*****************************'
ACCESS_KEY = '******************************'
ACCESS_SECRET = '****************************'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
fileObj=codecs.open('zegal.txt','r','utf-8')
f=fileObj.readlines()
fileObj.close()
for line in f:
api.update_status(line)
time.sleep(900)
当我运行“python zegal.py”时,这就起作用了,
但当我运行“heroku run worker”时,它不起作用。
它说“bash:zegal.py:command-notfound”,尽管我已经找到了
zegal.py、zegal.txt、procfile、requirements.txt都在同一个文件夹中
我在proc文件中写了“worker:zegal.py”
以及requirements.txt文件中的“tweepy==3.5.0”
我有一个heroku应用程序,因为我的文本文件有韩语句子,
我想我必须使用codecs.open和utf-8
我花了好几天的时间来解决这个问题,但这些解决方案都没有帮助。
我将工作目录添加到环境变量的路径中,然后
例如,我尝试了“导入os.path”
scriptpath = os.path.dirname(__file__)
filename = os.path.join(scriptpath, 'zegal.txt')
fileObj=codecs.open(filename,'r','utf-8')
f=fileObj.readlines()
fileObj.close()
但这也不起作用。我怎样才能解决这个问题?我完全是初学者。您需要编写完整的命令才能在Procfile中执行
worker: python zegal.py
只写python脚本的文件名是行不通的。你可以在Heroku docs中看到一个例子哦,这就是我以前尝试过的,而且成功了!我只是想,在没有“python”的情况下,还有另一种执行方式。你当然知道我错了。现在我按照你说的写完整的命令。我很感激。