Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Slidev addon for running Python code in your slides.

License

NotificationsYou must be signed in to change notification settings

kermanx/slidev-addon-python-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python runner for theMonaco Runner feature inSlidev. Code executed in browser usingPyodide.

Demo

Usage

Firstly, install the package:

npm install slidev-addon-python-runner

Then, add it as an addon in your headmatter inslides.md:

---addons:  -slidev-addon-python-runner# Optional configuration for this runnerpython:# Install packages from PyPI. Default: []installs:["cowsay"]# Code executed to set up the environment. Default: ""prelude:|    GREETING_FROM_PRELUDE = "Hello, Slidev!"# Automatically load the imported builtin packages. Default: trueloadPackagesFromImports:true# Disable annoying warning from `pandas`. Default: truesuppressDeprecationWarnings:true# Always reload the Python environment when the code changes. Default: falsealwaysReload:false# Options passed to `loadPyodide`. Default: {}loadPyodideOptions:{}---

To add an interactive Python code runner, use themonaco-run directive:

```py {monaco-run}from termcolorimport coloredprint(colored("Hello, Slidev!","blue"))```

Bundlepyodide

By default, when building slides (i.e.slidev build), thepyodide package will be replaced with the CDN version. This is because ofpyodide/pyodide#1949, which causes the imported python packages to be lost when using the bundled version.

To bundle the local version ofpyodide, set thePYODIDE_BUNDLE environment variable totrue. Note that in this way you can't import python packages in the static build.

About

A Slidev addon for running Python code in your slides.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp