我正在尝试使用无服务器框架和Python开发一个简单的无服务器应用程序。
这是我的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
运行sls deploy
时出现以下错误
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
我不确定我想念的是什么。错误消息对我没有帮助。
答案 0 :(得分:2)
AWS(Elastic Beanstalk)尚未包括python3.7(31/08/2019),请尝试将python版本降级至3.6,然后重试。
答案 1 :(得分:1)
在自定义部分中添加以下内容:
pythonRequirements:
pythonBin: python3
赞:
custom:
...
pythonRequirements:
pythonBin: python3
...
答案 2 :(得分:0)
检查在本地计算机上是否安装了runtime
(在您的情况下为python3.7
中指定的版本,
如果没有,请在安装后尝试检查。很有可能会解决问题