Pyodide
This allows for interactive Python execution. To use it, you need to install markdown-exec. See the documentation for more information.
It is very cool, but it has several limitations:
- While it should work well for most built-in Python modules, it does not support all of them. For instance, there is no support for
tkinter! - You can install packages from PyPi, but only pure Python modules are supported.
- There is support for some non-pure Python packages, such as
numpy.
import os, sys
print('cwd',os.getcwd())
for path in sys.path:
print(path)
which was run using:
| Markdown | |
|---|---|
1 2 3 4 5 6 7 | |
Packages of Project Hosted in GitHub¶
This will not work, pyodide cannot access your documentation, nor the installs at deployment.
from sandbox.calculations import Two_numbers
nums = Two_numbers(4, 2)
print(f'{nums.add()=}')
This is a not very elegant solution, but it works:
from pyodide_importer import register_hook
register_hook("https://raw.githubusercontent.com/lennon-c/SandBox_Mkdocs/main/")
from sandbox.calculations import Two_numbers
nums = Two_numbers(4, 2)
print(f'{nums.add()=}')