在AWS Lambda上运行python -m nltk.downloader -d $ NLTK_DATA punkt命令时出现SSL证书错误

时间:2019-06-17 20:12:56

标签: aws-lambda nltk aws-codestar

在使用aws codestar构建管道在aws lambda上部署以下代码时遇到SSL证书错误。

查看了多个社区讨论,没有任何结果。

version: 0.2

phases:
  install:
    commands:

      # Upgrade AWS CLI & PIP to the latest version
      - pip install --upgrade awscli
      - pip install --upgrade pip

      # Define Directories
      - export HOME_DIR=`pwd`
      - export NLTK_DATA=$HOME_DIR/nltk_data

  pre_build:
    commands:
      - cd $HOME_DIR

      # Create VirtualEnv to package for lambda
      - virtualenv venv
      - . venv/bin/activate

      # Install Supporting Libraries
      - pip install -U scikit-learn
      - pip install -U requests

      # Install WordNet
      - pip install -U nltk
      - python -m nltk.downloader -d $NLTK_DATA punkt

      # Output Requirements
      - pip freeze > requirements.txt

      # Discover and run unit tests in the 'tests' directory. For more information, see <https://docs.python.org/3/library/unittest.html#test-discovery>
      - python -m unittest discover tests

  build:
    commands:
      - cd $HOME_DIR
      - mv $VIRTUAL_ENV/lib/python3.6/site-packages/* .

1 个答案:

答案 0 :(得分:0)

对我有用的唯一方法是下载模块并将它们安装到nltk_data文件夹中的源文件夹中,然后创建一个Lambda环境变量NLTK,其值为./nltk_data