Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless: python3.7 not found! Try the pythonBin option

I'm trying to develop a simple serverless app using Serverless framework and Python.

Here's my serverless.yml

service: hello-world

provider:
  name: aws
  region: us-west-2
  runtime: python3.7
  environment:
    DB_ENDPOINT: 
    DB_USERNAME: 
    DB_PASSWORD: 

plugins:
  - serverless-python-requirements

functions:
  hello:
    handler: handler.trial_registration

When I run sls deploy I get following error

Serverless: Generated requirements from /home/ganesh/code/hello-world/requirements.txt in /home/ganesh/code/hello-world/.serverless/requirements.txt...
Serverless: Installing requirements from /home/ganesh/.cache/serverless-python-requirements/5c625dc5f843b3bb1163fd11989b43fb3cbca4299219c6ef399108fb36e56a2f_slspyc/requirements.txt ...
Serverless: Using download cache directory /home/ganesh/.cache/serverless-python-requirements/downloadCacheslspyc

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

  Error: python3.7 not found! Try the pythonBin option.
      at pipAcceptsSystem (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:100:13)
      at installRequirements (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:168:9)
      at installRequirementsIfNeeded (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:532:3)
      at ServerlessPythonRequirements.installAllRequirements (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:611:29)
      at ServerlessPythonRequirements.tryCatcher (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/promise.js:517:31)
      at Promise._settlePromise (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/promise.js:574:18)
      at Promise._settlePromise0 (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/promise.js:619:10)
      at Promise._settlePromises (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/promise.js:699:18)
      at _drainQueueStep (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/async.js:138:12)
      at _drainQueue (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/async.js:131:9)
      at Async._drainQueues (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/async.js:147:5)
      at Immediate.Async.drainQueues (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/async.js:17:14)
      at runCallback (timers.js:794:20)
      at tryOnImmediate (timers.js:752:5)
      at processImmediate [as _immediateCallback] (timers.js:729:5)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              8.10.0
     Framework Version:         1.51.0
     Plugin Version:            1.3.9
     SDK Version:               2.1.0

I'm not sure what am I missing. The error message is not helpful to me.

like image 787
Ganesh Satpute Avatar asked Aug 31 '19 17:08

Ganesh Satpute


2 Answers

Add the following in the custom section:

  pythonRequirements:
    pythonBin: python3

Like this:

custom:

...

  pythonRequirements:
    pythonBin: python3

...
like image 73
itsazzad Avatar answered Sep 30 '22 18:09

itsazzad


AWS (Elastic Beanstalk) didn't yet include python3.7 (31/08/2019), try to downgrade your python version to 3.6 and try again.

like image 21
Ilyas Avatar answered Sep 30 '22 17:09

Ilyas