Registry / devops / pyghidra

pyghidra

JSON →
library3.0.2pypypi✓ verified 86d ago

pyghidra is a Python package that provides a native CPython interface for Ghidra, the NSA's reverse engineering framework. Current version 3.0.2 supports Ghidra 12.x and requires Python >=3.9. It enables scripting Ghidra with standard Python and accessing its API directly within the Ghidra GUI or headlessly.

pip install pyghidra
INSTALL
IMPORT
SIG · PYGHIDRA
P
pyghidra
devopspythonv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pyghidra
import pyghidra
Direct import works; no submodule needed.
start
pyghidra.start()
from pyghidra import start
start is a top-level function in pyghidra module; direct import works but calling pyghidra.start() is clearer.
Ghidra API
from ghidra.program.model.listing import Function as GhidraFunction
import ghidra.program.model.listing
Ghidra API classes must be imported via full Java package path; pyghidra makes them accessible as Python modules.

Start Ghidra headlessly, load a binary, and iterate over its functions.

import pyghidra import os def analyze_binary(): binary_path = os.environ.get('BINARY_PATH', '/bin/ls') with pyghidra.start(binary_path) as ctx: program = ctx.getCurrentProgram() print(f"Analyzing: {program.getName()}") funcs = program.getFunctionManager().getFunctions(True) for func in funcs: print(func.getName()) if __name__ == '__main__': analyze_binary()
Debug
Known issues
gotchapyghidra requires a compatible Ghidra installation. Version 3.0.2 works with Ghidra 12.x; older versions (e.g., 2.x) are for Ghidra 11.x. Mixing versions causes import errors.
fix
Ensure GHIDRA_INSTALL_DIR environment variable points to the correct Ghidra version matching pyghidra.
affects: all
deprecatedThe `pyghidra.open()` function is deprecated in 3.0.0 and removed in later versions. Use `pyghidra.start()` as a context manager.
fix
Replace `pyghidra.open()` with `pyghidra.start()`.
affects: >=3.0.0
gotchaGhidra API classes are accessed with Python-style imports but follow Java package paths. Common mistake: using camelCase instead of PEP8 import style.
fix
Use full Java package path: e.g., `from ghidra.program.model.listing import Function`.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'start' from 'pyghidra'
pyghidra not installed or incompatible version.
fix
Install pyghidra with pip install pyghidra or upgrade to latest.
ValueError: Ghidra installation directory not set. Set GHIDRA_INSTALL_DIR environment variable.
Environment variable GHIDRA_INSTALL_DIR not set or pointing to invalid path.
fix
Set GHIDRA_INSTALL_DIR=/path/to/ghidra before running Python.
ghidra.program.model.listing.Function is not subscriptable
Calling list() or indexing on a function iterator incorrectly.
fix
Iterate directly: `for func in funcs:` or convert to list with list(funcs).
Upgrade
Version history
3.0.2latest on PyPI · released Jan 15, 2026
Audit
Dependencies
ghidrarequiredRequires a local Ghidra installation; pyghidra does not bundle it.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources