{"record":{"id":"3efe9264e2d82421","repo":"NationalSecurityAgency/ghidra","slug":"cannot-find-python-source-for-name-if-this-is","errorCode":null,"errorMessage":"\nCannot find Python source for {name}.\nIf this is a remote system, we shouldn't even be here. Chances are,\nthe Python dependencies required by ghidra on the remote system were\nremoved or replaced with incompatible versions. If this is a local\nsystem, your installation or development repo may be corrupt.\n","messagePattern":"\nCannot find Python source for (.+?)\\.\nIf this is a remote system, we shouldn't even be here\\. Chances are,\nthe Python dependencies required by ghidra on the remote system were\nremoved or replaced with incompatible versions\\. If this is a local\nsystem, your installation or development repo may be corrupt\\.\n","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/setuputils.py","lineNumber":38,"sourceCode":"missing on a remote target, and so the gmodutils.py file will not be\npresent. However, by the time such dependencies turn up missing,\nwhether remote or local, the PYTHONPATH should already include this\nmodule, and so we place the setup logic here.\n\"\"\"\nimport os\nfrom typing import List, Optional, Sequence\n\n\ndef ghidra_module_src(name: Optional[str]=None) -> str:\n    mod_home_name = 'MODULE_HOME' if name is None else f'MODULE_{name.replace(\"-\",\"_\")}_HOME'\n    mod_home = os.getenv(mod_home_name)\n    installed = f'{mod_home}/pypkg'\n    if os.path.isdir(installed):\n        return installed\n    dev = f'{mod_home}/src/main/py'\n    if os.path.isdir(dev):\n        return dev\n    raise Exception(f\"\"\"\nCannot find Python source for {name}.\nIf this is a remote system, we shouldn't even be here. Chances are,\nthe Python dependencies required by ghidra on the remote system were\nremoved or replaced with incompatible versions. If this is a local\nsystem, your installation or development repo may be corrupt.\n\"\"\")\n\n\ndef get_module_dependencies(name: str) -> List[str]:\n    src = ghidra_module_src(name)\n    # Can't rely on tomllib until Python 3.11 is minimum requirement.\n    # And, I'm in a place where I presume deps are missing, so do this garbage\n    # of a parse job.\n    with open(f\"{src}/pyproject.toml\") as project:\n        seen_deps = False\n        result: List[str] = []\n        for l in project.readlines():\n            l = l.strip()","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/setuputils.py#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the MODULE_*_HOME env var points at the correct, complete module directory.","On a remote system, reinstall/re-link the module's pypkg so $HOME/pypkg exists.","For dev, ensure the checkout includes src/main/py for the module."],"exampleFix":"# before: MODULE_HOME=/opt/ghidra (missing pypkg & src/main/py)\n# after\nexport MODULE_HOME=/path/to/Ghidra/Debug/Debugger-rmi-trace\nls $MODULE_HOME/src/main/py  # must exist","handlingStrategy":"validation","validationCode":"import os\nhome = os.getenv('MODULE_HOME') or os.getenv('MODULE_%s_HOME' % name.upper().replace('-', '_'))\nassert home and (os.path.isdir(f'{home}/pypkg') or os.path.isdir(f'{home}/src/main/py')), 'module home missing'","typeGuard":null,"tryCatchPattern":"try:\n    src = ghidra_module_src(name)\nexcept Exception:\n    # repair install / re-point MODULE_*_HOME\n    raise","preventionTips":["Set MODULE_*_HOME to a complete module directory.","Reinstall pypkg on remote trace systems after upgrades."],"tags":["setup","environment","installation","trace-rmi"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}