Inject code into a running Python process. Attach a Python shell or run arbitrary code inside an already-running Python interpreter. Current version 2.0. Release cadence is low, last updated 2019.
pip install pyrasiteNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Injects a simple print statement into the process with given PID. Requires gdb and ptrace permissions.
Install gdb (apt-get install gdb) and run: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
Use a full base image (e.g., ubuntu), or consider alternative methods like ptrace-based injectors.
Use pyrasite.inject(pid, code) instead of subprocess calls to pyrasite CLI.
Use the Python API: pyrasite.inject(pid, code)
Only inject into Python 3 processes; Python 2 target processes may crash.