在 sls 部署中获取无服务器错误生成 python3.8 ENOENT 以满足 python 要求

问题描述 投票:0回答:4

使用 sls deploy 进行无服务器部署并收到错误“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
python amazon-web-services serverless
4个回答
4
投票

我也遇到了同样的问题,但是使用的是 python 3.9。

在我的 serverless.yaml 文件中,我配置了

runtime: python3.9

在我的机器上,当我运行
python3 --version
时,结果是
3.9.5

经过一段时间的尝试理解,我终于发现,如果我尝试在我的机器中运行

python3.9 --version
它不起作用

试图将这些点联系起来,我想象无服务器框架程序需要确切的

python3.9
bin 名称。

为了解决这个问题,我从 Python Website 下载了二进制文件,安装了它并再次运行

serverless deploy
成功了!!!

如果您需要的话,可以帮助您进行安装(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

这个问题可能还有其他解决方案,例如使用 venv 或符号链接,但这个首先帮助了我。希望对你也有帮助。


3
投票

您本地可用的 python(当前路径)版本必须与 serverless.yml 提供程序运行时值中配置的版本相同。


0
投票

对我来说,当我将 serverless.yml 中的 python 版本从 3.8 更改为 3.6 时,它才起作用。


0
投票

我在 Mac 上收到了类似的消息;我跑了

brew install [email protected]
,它成功了。

© www.soinside.com 2019 - 2024. All rights reserved.