- Notifications
You must be signed in to change notification settings - Fork3
A Slidev addon for running Python code in your slides.
License
kermanx/slidev-addon-python-runner
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python runner for theMonaco Runner feature inSlidev. Code executed in browser usingPyodide.
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"))```
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.