问题
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'
- ''
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
I have tried to install the nltk packages into one of the search path shown in the log above.
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'))
any suggestions?
回答1:
You're mixing up the documentation for the standard environment with the one for the flexible environment.
Installing dependencies into the lib directory and using a appengine_config.py file is specific for the 1st generation standard environment.
For the flexible environment you specify your python dependencies using the requirements.txt file, see Using Python Libraries:
The Python runtime will automatically install all dependencies declared in your
requirements.txtduring deployment.
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?
Maybe of interest: How to tell if a Google App Engine documentation page applies to the 1st/2nd generation standard or the flexible environment
来源:https://stackoverflow.com/questions/56110708/problem-with-nltk-during-app-deployment-on-google-cloud