Install & Compatibility
Where this runs
tested against v0.0.18 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
36MB installed
● package 36MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Monty
✓ from pydantic_monty import Monty
✗ from monty import Monty
This quickstart demonstrates how to initialize the Monty VM, execute Python code within its sandboxed environment, and handle exceptions raised by the VM.
from monty import Monty, VmException
# Initialize the Monty VM
vm = Monty()
# Run some simple Python code inside the VM
result = vm.run('x = 10\ny = 20\nprint(x + y)')
print(f'stdout: {result.stdout.strip()!r}')
print(f'stderr: {result.stderr.strip()!r}')
print(f'return_value: {result.return_value!r}')
# Example of handling a VM-level exception
try:
vm.run('raise ValueError("Something went wrong in the sandbox!")')
except VmException as e:
print(f'VM error caught: {e}')
Debug
Known issues
gotchaMonty's VM is a sandboxed environment, meaning it has restricted access to many standard Python modules (e.g., `os`, `sys`, networking) and system resources by default. Code running within Monty cannot access the host filesystem or network unless explicitly configured (e.g., via `mount`).fixReview Monty's documentation for available built-ins and how to securely expose specific host resources like file paths via `vm.mount()` if necessary. Do not expect full standard library functionality without explicit configuration.
affects: All versions
gotchaAs of v0.0.12, the `zip()` built-in function in Monty enforces strict mode, raising a `ValueError` if iterables passed to it have different lengths. This differs from standard Python 3's `zip()`, which truncates to the shortest iterable.fixEnsure all iterables passed to `zip()` within Monty's VM have the same length. If different lengths are expected, manually handle the shorter iterable's termination or implement custom zipping logic.
affects: >=0.0.12
breakingThe library is in early development (`0.0.x` versioning), which means APIs are subject to change without strict adherence to semantic versioning. Breaking changes may occur in minor or patch releases.fixPin your `pydantic-monty` dependency to an exact version (e.g., `pydantic-monty==0.0.12`) and review release notes carefully when upgrading to newer versions to identify potential breaking changes.
affects: All `0.0.x` versions
Upgrade
Version history
0.0.18latest on PyPI · released May 29, 2026
Audit
Dependencies
No dependency data recorded yet.