【发布时间】:2021-11-02 04:49:12
【问题描述】:
我用 praw 制作了 python 文件,我正在尝试将 .py 文件上传到 github,然后使用 Heroku 执行应用程序。
我不断从 Heroku 收到一个错误,它找不到 praw。我在文件中设置了下载和导入它,但它不起作用?
pip install praw
import praw
previous_id="0"
reddit = praw.Reddit(
user_agent="by u/Sam-Kinison-Bot",
client_id="xxx",
client_secret="xxx",
username="Sam-Kinison-Bot",
password="xxx",)
previous_id="0"
def search():
for results in reddit.subreddit('all').comments():
global previous_id
body = results.body
body=body.lower()
comment_id = results.id
if comment_id == previous_id:
return "Error"
found=body.find('. it is a joke.')
if found != -1:
previous_id = comment_id
try:
results.reply('CAUSE IT IS A JOKE OHHH OHHH OHHHHHHHHHHHHH')
except:
break
以及我在尝试部署时在 herkou 上收到的错误消息:
Obtaining file:///tmp/build_d6ccc43e (from -r
/tmp/build_d6ccc43e/requirements.txt (line 1))
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize;
sys.argv[0] = '"'"'/tmp/build_d6ccc43e/setup.py'"'"';
__file__='"'"'/tmp/build_d6ccc43e/setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
--egg-base /tmp/pip-pip-egg-info-b6erccd7
cwd: /tmp/build_d6ccc43e/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/build_d6ccc43e/setup.py", line 1
pip install praw
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the
logs for full command output.
! Push rejected, failed to compile Python app.
! Push failed
有什么提示可以为我指明正确的方向吗?我应该把它全部扔掉并重新开始吗?
【问题讨论】:
标签: python heroku bots reddit praw