尝试从 AWS Lambda 运行 jupyter 笔记本 - 获取: "errorMessage" : "No such kernel named python3"



我正试图使用以下使用造纸厂的代码从Lambda运行Jupyter笔记本:

import os
import boto3
import subprocess
# to add paths
import sys
# pip install custom package to /tmp/ and add to path
subprocess.call('pip install papermill -t /tmp/ --no-cache-dir'.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
sys.path.insert(1, '/tmp/')
# papermill to execute notebook
import papermill as pm
def lambda_handler(event, context):
s3 = boto3.resource('s3')
print('Here')
s3.meta.client.download_file("testappend","ForTrigger.ipynb", "/tmp/juptest.ipynb")
print('Here')
pm.execute_notebook('/tmp/juptest.ipynb', '/tmp/juptest_output.ipynb', kernel_name='python3')
print('Here')
s3_client.upload_file("/tmp/juptest_output.ipynb", "testappend","temp/ForTriggerOutput.ipynb") 

程序抛出此错误:

"errorMessage": "No such kernel named python3",
"errorType": "NoSuchKernel"

我不知道如何找到可用内核的列表。请帮忙

提前谢谢。

我看到您的函数中有只安装造纸厂的代码。默认情况下,papermill只会安装jupyter和ipykernel-essential作为其依赖项的一部分,这不包括python3内核。在init代码中添加一个显式的ipykernel安装。

pip3 install ipykernel

以下是使用Papermill作为无服务器功能运行Jupyter Notebooks的另一种方法。你可能会觉得这很有用。

相关内容

最新更新