首页 > 解决方案 > 在谷歌云上部署应用程序期间出现 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'))

有什么建议么?

标签: google-app-enginedeploymentgoogle-cloud-platformnltk

解决方案


您将标准环境的文档与灵活环境的文档混为一谈。

将依赖项安装到lib目录中并使用appengine_config.py文件特定于第一代标准环境

对于使用该requirements.txt文件指定 Python 依赖项的灵活环境,请参阅使用 Python 库

Python 运行时将自动安装requirements.txt在部署期间声明的所有依赖项。

对于非 python 依赖项或那些不可 pip 安装的依赖项,您可以使用自定义运行时,请参阅Up-to-date pip with AppEngine Python flex env?

可能感兴趣:如何判断 Google App Engine 文档页面是否适用于第 1 代/第 2 代标准或柔性环境


推荐阅读