FileNotFoundError将Python / Flask应用程序部署到AWS Elastic Beanstalk-可能是本地磁盘问题?

时间:2019-01-31 13:16:56

标签: python-3.x amazon-elastic-beanstalk

任何人都可以帮助我理解...

FileNotFoundError: [Errno 2] No such file or directory: '/home/wsgi/.google-cookie'

...我正在运行一个Web应用程序(刮板),我刚刚从PythonAnywhere转移到了AWS Elastic Beanstalk,并且运行良好。在将其部署到AWS EB之前,它还在本地运行良好。

第一个网页加载成功并接受用户输入,但随后它立即掉落。查看日志输出,我怀疑我要导入的google-search模块需要本地磁盘访问,但这不匹配-您同意吗?

我是否需要将此映射到源包的.ebextensions目录中的python.config文件中?

我对使用AWS Lambda有点熟悉,但这是我第一次使用Elastic Beanstalk。

以下是日志中的相关摘录:

[Thu Jan 31 07:18:05.526679 2019] [:error] [pid 26879] [remote 151.230.55.234:24] [2019-01-31 07:18:05,524] ERROR in app: Exception on /form/step1 [POST]
[Thu Jan 31 07:18:05.526701 2019] [:error] [pid 26879] [remote 151.230.55.234:24] Traceback (most recent call last):
[Thu Jan 31 07:18:05.526704 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Thu Jan 31 07:18:05.526707 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     response = self.full_dispatch_request()
[Thu Jan 31 07:18:05.526710 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Thu Jan 31 07:18:05.526722 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     rv = self.handle_user_exception(e)
[Thu Jan 31 07:18:05.526724 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Thu Jan 31 07:18:05.526727 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     reraise(exc_type, exc_value, tb)
[Thu Jan 31 07:18:05.526759 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Thu Jan 31 07:18:05.526762 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     raise value
[Thu Jan 31 07:18:05.526764 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Thu Jan 31 07:18:05.526767 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     rv = self.dispatch_request()
[Thu Jan 31 07:18:05.526769 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Thu Jan 31 07:18:05.526771 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     return self.view_functions[rule.endpoint](**req.view_args)
[Thu Jan 31 07:18:05.526774 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/current/app/application.py", line 418, in form_step1
[Thu Jan 31 07:18:05.526776 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     topic_list = generate_topic_list(primary_topic)
[Thu Jan 31 07:18:05.526779 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/current/app/application.py", line 30, in generate_topic_list
[Thu Jan 31 07:18:05.526781 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     url_list = generate_URL_list(primary_keyword,n,l) #call URL generator routine in gsearch script. = 0  filename convention for primary scrape json files
[Thu Jan 31 07:18:05.526784 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/current/app/application.py", line 86, in generate_URL_list
[Thu Jan 31 07:18:05.526787 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     for url in search(query, tld = "co.uk", lang='en', pause = 2, stop=n): #can also add tld to limit to country e.g. tld='uk
[Thu Jan 31 07:18:05.526789 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/googlesearch/__init__.py", line 330, in search
[Thu Jan 31 07:18:05.526792 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     get_page(url_home % vars())
[Thu Jan 31 07:18:05.526794 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/googlesearch/__init__.py", line 151, in get_page
[Thu Jan 31 07:18:05.526796 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     cookie_jar.save()
[Thu Jan 31 07:18:05.526799 2019] [:error] [pid 26879] [remote 151.230.55.234:24]   File "/usr/lib64/python3.6/http/cookiejar.py", line 1875, in save
[Thu Jan 31 07:18:05.526801 2019] [:error] [pid 26879] [remote 151.230.55.234:24]     with open(filename, "w") as f:
[Thu Jan 31 07:18:05.526805 2019] [:error] [pid 26879] [remote 151.230.55.234:24] FileNotFoundError: [Errno 2] No such file or directory: '/home/wsgi/.google-cookie'

0 个答案:

没有答案