NationalSecurityAgency/ghidra · critical · Exception

Cannot find Python source for {name}. If this is a remote s

Error message

Cannot find Python source for {name}.
If this is a remote system, we shouldn't even be here. Chances are,
the Python dependencies required by ghidra on the remote system were
removed or replaced with incompatible versions. If this is a local
system, your installation or development repo may be corrupt.

What it means

Raised as a generic Exception by ghidra_module_src() when, for a given module, neither the installed pypkg directory ($MODULE_*_HOME/pypkg) nor the dev source directory ($MODULE_*_HOME/src/main/py) exists on disk. The function is used during setup/dependency discovery to locate a module's Python sources, so failure means the Ghidra module home is missing or misconfigured.

Source

Thrown at Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/setuputils.py:38

missing on a remote target, and so the gmodutils.py file will not be
present. However, by the time such dependencies turn up missing,
whether remote or local, the PYTHONPATH should already include this
module, and so we place the setup logic here.
"""
import os
from typing import List, Optional, Sequence


def ghidra_module_src(name: Optional[str]=None) -> str:
    mod_home_name = 'MODULE_HOME' if name is None else f'MODULE_{name.replace("-","_")}_HOME'
    mod_home = os.getenv(mod_home_name)
    installed = f'{mod_home}/pypkg'
    if os.path.isdir(installed):
        return installed
    dev = f'{mod_home}/src/main/py'
    if os.path.isdir(dev):
        return dev
    raise Exception(f"""
Cannot find Python source for {name}.
If this is a remote system, we shouldn't even be here. Chances are,
the Python dependencies required by ghidra on the remote system were
removed or replaced with incompatible versions. If this is a local
system, your installation or development repo may be corrupt.
""")


def get_module_dependencies(name: str) -> List[str]:
    src = ghidra_module_src(name)
    # Can't rely on tomllib until Python 3.11 is minimum requirement.
    # And, I'm in a place where I presume deps are missing, so do this garbage
    # of a parse job.
    with open(f"{src}/pyproject.toml") as project:
        seen_deps = False
        result: List[str] = []
        for l in project.readlines():
            l = l.strip()

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the MODULE_*_HOME env var points at the correct, complete module directory.
  2. On a remote system, reinstall/re-link the module's pypkg so $HOME/pypkg exists.
  3. For dev, ensure the checkout includes src/main/py for the module.

Example fix

# before: MODULE_HOME=/opt/ghidra (missing pypkg & src/main/py)
# after
export MODULE_HOME=/path/to/Ghidra/Debug/Debugger-rmi-trace
ls $MODULE_HOME/src/main/py  # must exist
Defensive patterns

Strategy: validation

Validate before calling

import os
home = os.getenv('MODULE_HOME') or os.getenv('MODULE_%s_HOME' % name.upper().replace('-', '_'))
assert home and (os.path.isdir(f'{home}/pypkg') or os.path.isdir(f'{home}/src/main/py')), 'module home missing'

Try / catch

try:
    src = ghidra_module_src(name)
except Exception:
    # repair install / re-point MODULE_*_HOME
    raise

Prevention

When it happens

Trigger: MODULE_HOME / MODULE_<NAME>_HOME env var points at a non-existent or partial install; the pypkg was deleted on a remote trace system; running the trace bridge against a corrupt dev checkout.

Common situations: Remote trace machine where ghidra's python deps were removed/replaced with incompatible versions; dev repo missing the py source tree; wrong MODULE_HOME after relocation.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/3efe9264e2d82421. Report an issue: GitHub.