Running the following command inside a virtual environment triggers this error on Windows:
Failed to find the PyRuntime section in process 29072 on Windows platform
python -m profiling.sampling run --subprocesses -m test test_gc
I suspect this happens because virtual environments use shims to launch the original interpreter. Since the shim itself isn't a Python process, that's why profiling.sampling fails.
We can work around this: if --subprocesses option specified then we should proceed with profiling as long as at least one child process is a Python process.
Activity
pablogsal commented on Apr 23, 2026
I think at the very least we should improve the error message if we are sure enough that's the case. Could you make a PR for that @sergey-miryanov ?
sergey-miryanov commented on Apr 24, 2026
Yes, will try to do.
GH-148932: Improve error message if profiling.sampling run from venv …
gh-148932: Docs / `profiling.sampling` Windows limitations (#150272)
[3.15] gh-148932: Docs / `profiling.sampling` Windows limitations (GH…
gh-148932: Fix `profiling.sampling` on Windows virtual environments (#…
[3.15] gh-148932: Fix `profiling.sampling` on Windows virtual environ…
pythongh-148932: Fix `profiling.sampling` on Windows virtual environm…