google-app-engine - 在谷歌云上部署应用程序期间出现 nltk 问题
问题描述
我尝试在 gcloud 应用引擎上部署我的应用程序,当部署完成并尝试浏览 URL 时,出现 502 服务器错误。日志显示nltk包有问题:
[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 文件中提出了必要的硬件要求:
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 包安装到上面日志中显示的搜索路径之一。
另外,我创建了应用引擎配置文件:
# 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'))
有什么建议么?
解决方案
您将标准环境的文档与灵活环境的文档混为一谈。
将依赖项安装到lib
目录中并使用appengine_config.py
文件特定于第一代标准环境。
对于使用该requirements.txt
文件指定 Python 依赖项的灵活环境,请参阅使用 Python 库:
Python 运行时将自动安装
requirements.txt
在部署期间声明的所有依赖项。
对于非 python 依赖项或那些不可 pip 安装的依赖项,您可以使用自定义运行时,请参阅Up-to-date pip with AppEngine Python flex env?
推荐阅读
- jenkins - Jenkins 在给定的时间间隔触发构建步骤/阶段(不是整个作业)
- c# - C# - 对象列表 - 访问对象的参数
- sql - SQL 查询 - 转换时返回特定项目参数错误的结果
- cpu - 在超级简单 CPU 上:超级简单 CPU 上两个输入的 GCD
- r - 如何处理 R 中不平衡的数据集?
- django - Django - “NoneType”对象没有属性“线程”
- java - 带字符串且无参数的方法
- c# - Unity ADS -“广告”不包含“AddListener”的定义
- c++ - 如何在 C++ 中使用 boost-property-tree 从 JSON 文件中读取对象数组
- azure - Azure 容器实例成功/失败时的电子邮件警报/日志