A CLI tool to visualize Python code execution locally.
Project description
⚡ PyViz Tutor
A modern, offline execution visualizer for Python. Trace your code step-by-step in a beautiful, dark-mode interface.
🚀 What is it?
PyViz Tutor is a CLI tool that works like https://pythontutor.com/ but runs entirely on your local machine.
It executes your Python script, captures the line-by-line execution flow (variables, stack, output), and generates a single, self-contained HTML file. Perfect for debugging algorithms, teaching programming concepts, or understanding complex logic with a VS Code-inspired visual interface.
✨ Features
- 🔒 100% Offline: No data leaves your machine. Everything runs locally.
- 🎨 Modern UI: Beautiful Dark Mode interface inspired by modern IDEs.
- 📦 Zero-Dependency Output: Generated HTML file has all CSS/JS embedded. Share it easily.
- ⏪ Time Travel: Scrub through execution with slider or play/pause controls.
- 🕵️ Variable Explorer: Watch local variables change state in real-time with color-coded types.
- 🖥️ Standard Output: View
print()statements exactly as they appear during execution.
📦 Installation
Install globally using pip or uv:
# Standard way
pip install pyviz-tutor
# Modern, fast way (Recommended)
uv tool install pyviz-tutor
🎮 Usage
Create a Python script (e.g., recursion.py):
def factorial(n):
if n == 0: return 1
return n * factorial(n-1)
print(factorial(5))
Run the visualizer:
pyviz recursion.py
Your browser will automatically open viz.html showing the trace.
🔧 How it Works
- Tracer: Uses
sys.settraceto record interpreter state at every line. - Serializer: Converts complex objects safely into string representations.
- Bundler: Injects trace data into a pre-built HTML template with a reactive frontend.
🛠️ Development
Want to contribute or modify the source?
# Clone the repo
git clone https://github.com/azmatsiddique/pyviz-tutor.git
cd pyviz-tutor
# Install dependencies using uv
uv venv
uv pip install -e .
# Run tests
pyviz tests/test_script.py
📝 License
Distributed under the MIT License. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyviz_tutor-0.1.2.tar.gz.
File metadata
- Download URL: pyviz_tutor-0.1.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3683e7d0654e91e1960c20670cc1829b3a038e2165dd2fc76b8c30b208574966
|
|
| MD5 |
01c25c0edb32de8633e0ecccd4cf8092
|
|
| BLAKE2b-256 |
28868c688504bc08143c7e3e338e2d54f5e40101342080ff51149cc705ac2a7a
|
File details
Details for the file pyviz_tutor-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pyviz_tutor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80d50dce443f30c35526ef22fd09a97c8f2d18ee19306d76cff94b7f896b3fd7
|
|
| MD5 |
dc4a22e247ce7c2408f489f7c5ea41b4
|
|
| BLAKE2b-256 |
572a38d76447e9739feaec46b05fbffef21835097a16f3c5aeadfacd7d0417fc
|