【问题标题】:Node JS runtime but requires pythonNode JS 运行时,但需要 python
【发布时间】:2021-04-06 00:45:36
【问题描述】:

我通过 AWS lambda(节点 14)上的简单 JS lambda 函数使用 https://www.npmjs.com/package/youtube-dl-exec。 该代码非常简单,并根据给定的 URL 收集信息(并受 YTDL 支持)。我已经用 jest 进行了测试,它在我安装了 python 2.7 的本地上运行良好。

我的 package.json 依赖项看起来像

 "dependencies": {
    "youtube-dl": "^3.5.0",
    "youtube-dl-exec": "^1.2.0"
},
  "devDependencies": {
    "jest": "^26.6.3"
  }

我正在使用 github 操作将代码部署到使用 main.yml 文件推送到 master:

name: Deploy to AWS lambda
on: [push]
jobs:
  deploy_source:
    name: build and deploy lambda
    strategy:
      matrix:
        node-version: [14.x]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: npm install and build
        run: |
          npm ci
          npm run build --if-present
        env:
          CI: true
      - uses: actions/setup-python@v2
        with:
          python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
          architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
      - name: zip
        uses: montudor/action-zip@v0.1.0
        with:
          args: zip -qq -r ./bundle.zip ./
      - name: default deploy
        uses: appleboy/lambda-action@master
        with:
          aws_access_key_id: ${{ secrets.AWS_EEEEE_ID }}
          aws_secret_access_key: ${{ secrets.AWS_EEEEE_KEY }}
          aws_region: us-EEEEE
          function_name: DownloadEEEEE
          zip_file: bundle.zip

我得到了一个

    INFO    Error: Command failed with exit code 127: /var/task/node_modules/youtube-dl-exec/bin/youtube-dl https://www.EXQEEEE.com/p/XCCRXqXInEEZ4W4 --dump-json --no-warnings --no-call-home --no-check-certificate --prefer-free-formats --youtube-skip-dash-manifest
/usr/bin/env: python: No such file or directory
    at makeError (/var/task/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/var/task/node_modules/execa/index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  shortMessage: 'Command failed with exit code 127: /var/task/node_modules/youtube-dl-exec/bin/youtube-dl https://www.instagram.com/p/CCRq_InFZ44 --dump-json --no-warnings --no-call-home --no-check-certificate --prefer-free-formats --youtube-skip-dash-manifest',
  command: '/var/task/node_modules/youtube-dl-exec/bin/youtube-dl https://www.EXQEEEE.com/p/XCCRXqXInEEZ4W4 --dump-json --no-warnings --no-call-home --no-check-certificate --prefer-free-formats --youtube-skip-dash-manifest',
  exitCode: 127,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: '/usr/bin/env: python: No such file or directory',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

error.

我尝试添加一个 lambda 层,在 main.yml 文件中添加 python,并通过依赖项进行安装,但也许我做错了什么,因此库无法在 /usr/bin/env 找到 python。

  • 如何使 python 在该路径中可用?
  • 我不应该在 lambda config (main.yml) 上使用 ubuntu-latest,因为它默认不包含 python 吗?

任何帮助将不胜感激。

注意:出于隐私目的,我对 URL 进行了混淆处理。

【问题讨论】:

  • 你好 Saurav,你成功了吗?
  • @AwoladHossain 我不得不选择一个 docker 容器镜像。

标签: python node.js lambda youtube-dl aws-lambda-layers


【解决方案1】:

新的 nodejs10.x Lambda 运行时不再包含 python,因此 youtube-dl 不起作用

【讨论】:

  • 那有什么解决办法呢?
猜你喜欢
  • 1970-01-01
  • 2020-06-02
  • 2023-01-11
  • 2013-01-06
  • 2013-02-05
  • 2017-04-10
  • 1970-01-01
  • 2017-10-06
  • 2016-09-29
相关资源
最近更新 更多