我正在使用 AppEngine 制作一个Web应用程序,该应用程序使用 Spotify 和 Reddit API,并使其在{{1} },但是当我上传项目并在网站版本上尝试完全相同的操作时,出现错误:
dev_appserver.py
我在提交表单后收到此错误,然后该表单应该运行网络抓取程序,但只是立即出错。我发现很多人在自己制作的文件上存在相同的Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/350d926c06a7e859/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/350d926c06a7e859/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
...
...
File "/base/data/home/apps/s~kabloombox-219016/20190116t005128.415435515961651480/main.py", line 274, in post
scan_subreddit(language, access_token)
File "/base/data/home/apps/s~kabloombox-219016/20190116t005128.415435515961651480/main.py", line 190, in scan_subreddit
reddit = praw.Reddit(client_id=CLIENT_ID_REDDIT, client_secret=CLIENT_SECRET_REDDIT, user_agent=USER_AGENT)
...
...
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/350d926c06a7e859/python27/python27_dist/lib/python2.7/platform.py", line 165, in libc_ver
f = open(executable,'rb')
IOError: [Errno 2] No such file or directory: '/base/alloc/tmpfs/dynamic_runtimes/python27g/350d926c06a7e859/python27/python27_dist/python'
错误,只需要更改app.yaml,但是No such file or directory
是随机的/base/alloc/tmpfs/dynamic_runtimes/python27g/350d926c06a7e859/python27/python27_dist/python
,我绝对没有知道我应该怎么做。
答案 0 :(得分:1)
您可以更改Praw初始化,以防止其调用platform.platform():
r = praw.Reddit(user_agent='...', disable_update_check=True)
或修补platform.platform()以在 appengine_config.py 中返回字符串文字:
import platform
def patch(module):
def decorate(func):
setattr(module, func.func_name, func)
return func
return decorate
@patch(platform)
def platform():
return 'AppEngine'