问题描述
我试图在gcloud应用引擎上部署应用程序,当部署完成并且尝试浏览URL时,出现502服务器错误.日志显示nltk软件包有问题:
I tried to deploy my application on gcloud app engine, when the deployment finish and I tried to brows the URL, I got 502 server error. The log shows that there is problem with nltk package:
[31m>>> import nltk
>>> nltk.download('punkt')
[0m
Searched in:
- '/root/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
- '/env/nltk_data'
- '/env/lib/nltk_data'
- ''
我已经在我的app.yaml文件中添加了必要的硬件要求:
I have put the necessary hardware requirement on my app.yaml file :
service: vapi
runtime: python
env: flex
health_check:
enable_health_check: True
check_interval_sec: 5
timeout_sec: 4
unhealthy_threshold: 2
healthy_threshold: 2
entrypoint: gunicorn -b :$PORT wsgi:app
runtime_config:
python_version: 3.5
resources:
cpu: 2
memory_gb: 8
disk_size_gb: 20
我试图将nltk软件包安装到上面日志中显示的搜索路径之一中.
I have tried to install the nltk packages into one of the search path shown in the log above.
另外,我还创建了App Engine配置文件:
also, I have created app engine configuration file:
# appengine_config.py
from google.appengine.ext import vendor
# Add any libraries install in the "lib" folder.
vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))
有什么建议吗?
推荐答案
您正在将标准环境的文档与灵活环境的文档混在一起.
You're mixing up the documentation for the standard environment with the one for the flexible environment.
在lib
目录中安装依赖项并使用appengine_config.py
文件是特定于第一代标准环境.
Installing dependencies into the lib
directory and using a appengine_config.py
file is specific for the 1st generation standard environment.
对于灵活的环境,您可以使用requirements.txt
文件指定python依赖项,请参见使用Python库:
For the flexible environment you specify your python dependencies using the requirements.txt
file, see Using Python Libraries:
对于非python依赖项或不能pip安装的依赖项,可以使用自定义运行时,请参见
For non-python dependencies or those which aren't pip-installable you can use a custom runtime, see Up-to-date pip with AppEngine Python flex env?
可能感兴趣:
这篇关于在Google Cloud上部署应用程序期间出现Nltk问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!