Guppy 3 is a comprehensive Python programming environment and heap analysis toolset, primarily serving as a port of the original Guppy-PE (Guppy-Python Environment) from Python 2 to Python 3. It provides robust tools for object and heap memory sizing, profiling, and analysis, essential for debugging memory-related issues and optimizing Python program performance. The library consists of subpackages like `heapy` for detailed heap introspection, `gsl` for a specification language, and `sets` for C-implemented bitsets and nodesets. The project maintains an active development status with regular minor releases.
pip install guppy3Verified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize the `heapy` profiler, set a reference point, allocate some objects, and then take a heap snapshot to analyze memory usage. It also shows how to isolate specific objects for inspection.
Ensure your environment uses Python 3.10, 3.11, 3.12, 3.13, or 3.14. Check `guppy3` PyPI page for the latest `Requires-Python` metadata.
Only use `guppy3` with standard CPython interpreters. Avoid using it in environments that implement or enable free-threading.
Install `Tkinter` (e.g., `sudo apt-get install python3-tk` on Debian/Ubuntu, or ensure your Python distribution includes it).
If experiencing silent termination, try isolating `guppy3` usage from TensorFlow operations or investigate specific interaction points. Consider alternative memory profilers if direct integration causes issues.
Ensure `pywin32` is updated to the latest version (`pip install -U pywin32`) if encountering stability issues on Windows.
Ensure you are using `from guppy import hpy` after installing `guppy3`, and that no other `guppy` installations or conflicting packages are present. The `hpy()` function is exposed directly by the `guppy` package. If this exact error occurs, it often means the `guppy3` package itself might be corrupted or an older `guppy` (Python 2) package is interfering. Reinstalling `guppy3` in a clean environment is a good first step.
On Debian/Ubuntu, install `build-essential` and `python3-dev` (or `python-dev` for Python 2, though `guppy3` is for Python 3): `sudo apt-get update && sudo apt-get install build-essential python3-dev`. On Fedora/RHEL, use `sudo dnf install @development-tools python3-devel`. On macOS, install Xcode Command Line Tools: `xcode-select --install`. Ensure your environment variables are correctly set for the compiler.
You need to compile `guppy3` in the target `musl` environment itself, or use a pre-built wheel that is compatible with `musl`. If using Docker, ensure your build stage for installing `guppy3` uses an Alpine-based image that has development tools installed (`apk add build-base python3-dev`) to compile it directly, or switch to a `glibc`-based image (e.g., Debian or Ubuntu). For example, `RUN apk add build-base python3-dev && pip install guppy3`.
Upgrade your `pywin32` package to version 300 or newer: `pip install -U pywin32`. If the issue persists, ensure all other dependencies are up to date and consider testing in a fresh virtual environment.