【问题标题】:Trying to run a jupyter notebook from AWS Lambda - getting: "errorMessage": "No such kernel named python3"尝试从 AWS Lambda 运行 jupyter 笔记本 - 得到:“errorMessage”:“没有名为 python3 的内核”
【发布时间】:2021-03-22 10:41:15
【问题描述】:

我正在尝试使用以下代码从 Lambda 运行 Jupyter notebook:

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"

我不确定如何查找可用内核列表。请帮忙。

提前致谢。

【问题讨论】:

    标签: python-3.x aws-lambda jupyter-notebook papermill


    【解决方案1】:

    我看到你的函数中有代码来安装造纸厂。默认情况下,papermill 只会安装 jupyter 和 ipykernel 必要的作为其依赖项的一部分,并且不包括 python3 内核。在你的初始化代码中添加一个显式的 ipykernel 安装。

    pip3 install ipykernel
    

    Here 是使用 Papermill 作为无服务器功能运行 Jupyter Notebooks 的另一种方式。您可能会发现这很有用。

    【讨论】:

      猜你喜欢
      • 2019-08-07
      • 2016-11-10
      • 1970-01-01
      • 2021-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多