benfred/py-spy · critical

32-bit python is unsupported on windows

Error message

32-bit python is unsupported on windows

What it means

py-spy cannot profile 32-bit Python processes on Windows. When scanning the loaded modules of a target process, the code detects a python DLL whose version string contains "32 bit" and deliberately panics, because unwinding a 32-bit Python process is unimplemented and returning an error would cause callers to silently fall back to other version-detection methods and fail later in confusing ways.

Source

Thrown at src/version.rs:47

            let major = std::str::from_utf8(&cap[2])?.parse::<u64>()?;
            let minor = std::str::from_utf8(&cap[3])?.parse::<u64>()?;
            let patch = std::str::from_utf8(&cap[4])?.parse::<u64>()?;
            let build_metadata = if let Some(s) = cap.get(7) {
                Some(std::str::from_utf8(&s.as_bytes()[1..])?.to_owned())
            } else {
                None
            };

            let version = std::str::from_utf8(&cap[0])?;
            info!("Found matching version string '{}'", version);
            #[cfg(windows)]
            {
                if version.contains("32 bit") {
                    error!("32-bit python is not yet supported on windows! See https://github.com/benfred/py-spy/issues/31 for updates");
                    // we're panic'ing rather than returning an error, since we can't recover from this
                    // and returning an error would just get the calling code to fall back to other
                    // methods of trying to find the version
                    panic!("32-bit python is unsupported on windows");
                }
            }

            return Ok(Version {
                major,
                minor,
                patch,
                release_flags: release.to_owned(),
                build_metadata,
            });
        }
        Err(format_err!("failed to find version string"))
    }
}

impl std::fmt::Display for Version {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(

View on GitHub (pinned to 32080cc0c2)

Solutions

  1. Install and run 64-bit Python (the x86-64 Windows installer) and profile that interpreter instead.
  2. Verify the target interpreter bitness (python -c "import struct;print(struct.calcsize('P')*8)") and ensure py-spy is pointed at the 64-bit process via --pid.
  3. If 32-bit support is required, track/raise the issue at https://github.com/benfred/py-spy/issues/31 rather than attempting a workaround.
  4. On Linux/macOS no such restriction exists; alternatively run the workload under WSL with 64-bit Python.

Example fix

// before: profiling with 32-bit Python on Windows
C:\py> py-spy dump --pid 1234  # panics: 32-bit python is unsupported on windows
// after: use a 64-bit interpreter
C:\py> python -c "import struct;print(struct.calcsize('P')*8)"  # ensure 64
C:\py> py-spy dump --pid <pid of 64-bit python>
Defensive patterns

Strategy: validation

Validate before calling

import struct, sys
if sys.platform == 'win32' and struct.calcsize('P') * 8 == 32:
    raise SystemExit('py-spy cannot profile 32-bit Python on Windows; use a 64-bit interpreter')

Prevention

When it happens

Trigger: Calling py-spy (dump/record) against a 32-bit Python interpreter on Windows: scan_bytes reads the python DLL's version info and it contains "32 bit", reaching the panic at src/version.rs:47.

Common situations: A user on Windows installed the x86 (32-bit) build of Python (common on older machines or when a 32-bit installer was downloaded by mistake) and tries to profile their script; or profiling an app that embeds a 32-bit Python DLL.

Related errors


AI-assisted analysis of benfred/py-spy@32080cc0c2 (2026-09-05). Data as JSON: /api/errors/ee3fc6953683a162. Report an issue: GitHub.