9

Doing a serverless deployment using sls deploy and getting error "spawn python3.8 ENOENT"

ubuntu@jumpboxAndawscli:$ sudo sls deploy --stage prod
Serverless: Configuration warning at ‘provider’: unrecognized property ‘configfile’
Serverless:
Serverless: Learn more about configuration validation here:
Serverless:
Serverless: Updated deployment bucket public access block
Serverless: [serverless-package-external] is complete
Serverless: Generated requirements from /data/integrations/requirements.txt in /data/integrations/.serverless/requirements.txt…
Serverless: Installing requirements from /home/ubuntu/.cache/serverless-python-requirements/c83840509c18324c044b580033bb40d7104080235af12a1d9e3d118cf0675070_x86_64_slspyc/requirements.txt …
Serverless: Using download cache directory /home/ubuntu/.cache/serverless-python-requirements/downloadCacheslspyc

Error ---------------------------------------------------

Error: spawn python3.8 ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:470:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

 For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Your Environment Information ---------------------------
Operating System: linux
Node Version: 12.22.1
Framework Version: 2.72.2
Plugin Version: 5.5.4
SDK Version: 4.3.1
Components Version: 3.18.2

5 Answers 5

6

Your local available python (current PATH) version MUST be the same version configured in your serverless.yml provider runtime value.

Sign up to request clarification or add additional context in comments.

Comments

4

I had the same problem, but with python 3.9.

In my serverless.yaml file I had the runtime: python3.9 configured.
In my machine, when I ran python3 --version the result was 3.9.5.

After some time trying to understand, I finally saw that if I tried to run python3.9 --version in my machine, it didn't work.

Trying to connect the dots, I imagined that the serverless framework program needed the exact python3.9 bin name.

To solve the problem I downloaded the binaries from the Python Website, installed it and ran serverless deploy again. It worked!!!

To help you with the installation, in case you need (Ubuntu):

$ cd /opt
$ sudo wget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz
$ sudo tar xzf Python-3.9.13.tgz
$ cd Python-3.9.13
$ sudo ./configure --enable-optimizations
$ sudo make altinstall

There are probably other solutions for this problem like using venv or symlinks, but this one helped me first. I hope it helps you too.

Comments

0

For me, when I changed the python version from 3.8 to 3.6 in serverless.yml then only it worked.

Comments

0

I got a similar message on Mac; I ran brew install [email protected], and it worked.

Comments

0

In the file

serverless.yaml, 

setup

runtime: python3.11

#Example

/mydir_py3_11/django_aws_lambda_002/django-aws-lambda/serverless.yaml

service: django-aws-lambda

plugins:
  - serverless-dotenv-plugin
  - serverless-prune-plugin
  - serverless-python-requirements
  - serverless-wsgi
useDotenv: true
variablesResolutionMode: 20210326

custom:
  dotenv:
    logging: false
  pythonRequirements:
    dockerizePip: non-linux
    zip: true
    fileName: requirements.txt
  stage: ${env:STAGE, 'default'}
  wsgi:
    app: django_aws_lambda.wsgi.application
    packRequirements: false
  prune:
    automatic: true
    number: 3

functions:
  - app:
      handler: wsgi_handler.handler
      events:
        - http: ANY /
        - http: ANY /{proxy+}
      timeout: 30

provider:
  name: aws
  role: arn:aws:iam::198784529794:role/exec_lambda
  profile: admin
  region: us-east-1
  runtime: python3.11
  versionFunctions: false
  stage: ${env:STAGE, 'default'}
  timeout: 60
  vpc:
    securityGroupIds:
      - sg-e2a9ddd5
      - sg-01d23aa5252981a2b
    subnetIds:
      - subnet-5751da76
      - subnet-36aa2369
      - subnet-65ea6603
      - subnet-3927f708
      - subnet-31623e7c
      - subnet-ff4f09f1
  deploymentBucket:
    name: ${env:DEPLOYMENT_BUCKET}
  apiGateway:
    shouldStartNameWithService: true
  lambdaHashingVersion: 20201221

package:
  individually:
    true
  exclude:
    - .cache/**
    - .env
    - .git/**
    - .github/**
    - .pytest_cache/**
    - .serverless/**
    - node_modules/**
    - static/**
    - db.sqlite3

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.