Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node JS runtime but requires python

I am utilizing https://www.npmjs.com/package/youtube-dl-exec through a simple JS lambda function on an AWS lambda (node 14). The code is pretty simple and gathers info as per the URL given (and supported by YTDL). I have done testing with jest and it works well on my local where python 2.7 is installed.

My package.json dependencies look like

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

I am using github action to deploy the code on push to master using main.yml file:

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/[email protected]
        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

I am getting a

    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.

I have tried adding a lambda layer, adding python in the main.yml file, and also installing through dependency but perhaps I am doing something wrong so that the library is not able to find python at /usr/bin/env.

  • How do I make python be available in that path?
  • Should I not use ubuntu-latest on lambda config (main.yml) since it doesn't come packed with python by default?

Any help would be appreciated.

Note: I have obfuscated the URLs for privacy purposes.

like image 480
Saurav Prakash Avatar asked Feb 12 '26 10:02

Saurav Prakash


1 Answers

The new nodejs10.x Lambda runtime does not contain python anymore, and therefore, youtube-dl does not work

like image 191
inayatu Avatar answered Feb 13 '26 22:02

inayatu