{"record":{"id":"f9479517f4241a3e","repo":"NationalSecurityAgency/ghidra","slug":"cannot-find-python-source-for-name-try-gradle-a","errorCode":null,"errorMessage":"Cannot find Python source for {name}. Try gradle assemblePyPackage?","messagePattern":"Cannot find Python source for (.+?)\\. Try gradle assemblePyPackage\\?","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-rmi-trace/data/support/gmodutils.py","lineNumber":43,"sourceCode":"that minimal logic is required to get it loaded.\n\nThis file CANNOT be assumed to be available on a remote target. For\nthat, consider ghidratrace.setuputils.\n\"\"\"\nimport os\nfrom typing import Optional\n\n\ndef ghidra_module_pypath(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/src'\n    if os.path.isdir(installed):\n        return installed\n    dev = f'{mod_home}/build/pypkg/src'\n    if os.path.isdir(dev):\n        return dev\n    raise Exception(\n        f\"Cannot find Python source for {name}. Try gradle assemblePyPackage?\")\n","sourceCodeStart":25,"sourceCodeEnd":45,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-rmi-trace/data/support/gmodutils.py#L25-L45","documentation":"Raised by ghidra_module_pypath() in gmodutils.py when neither '<MODULE_HOME>/pypkg/src' (installed layout) nor '<MODULE_HOME>/build/pypkg/src' (dev/build layout) exists as a directory. This helper locates the Python source package for a Ghidra module so launchers can set PYTHONPATH; failure means the module's Python package was never built or installed.","triggerScenarios":"A Windows launch script imports gmodutils and calls ghidra_module_pypath('Debugger-jpda') (or similar) before the module's pypkg has been assembled. The MODULE_<NAME>_HOME environment variable points at a directory tree lacking both the installed and build pypkg/src subpaths.","commonSituations":"Running a launcher directly from a source checkout without first executing 'gradle assemblePyPackage'; an incomplete or partially-built installation; the MODULE_HOME/MODULE_<NAME>_HOME env var pointing at the wrong root; a fresh clone that was only built with 'gradle build' but not the py-package target.","solutions":["Run the Gradle task: './gradlew assemblePyPackage' (or ':Debugger-jpda:assemblePyPackage') to generate the pypkg/src directory.","Verify the MODULE_HOME (or MODULE_<NAME>_HOME) environment variable points at the correct module root containing the built pypkg.","If using a distributed Ghidra install, re-install or re-extract so the pypkg/src subtree is present under the module directory."],"exampleFix":"# before — pypkg not built yet\n# (env) MODULE_HOME=/path/to/module without pypkg/src\n\n# after\n# shell\n./gradlew :Debugger-jpda:assemblePyPackage\n# then re-run the launcher with MODULE_HOME set to the module root","handlingStrategy":"validation","validationCode":"import os\nmod_home = os.getenv('MODULE_HOME') or os.getenv(f'MODULE_{name.replace(\"-\",\"_\")}_HOME')\nif not (mod_home and os.path.isdir(f'{mod_home}/pypkg/src') or os.path.isdir(f'{mod_home}/build/pypkg/src')):\n    raise SystemExit('Run: ./gradlew assemblePyPackage before launching')","typeGuard":null,"tryCatchPattern":"try:\n    from gmodutils import ghidra_module_pypath\n    pypath = ghidra_module_pypath(name)\nexcept Exception as e:\n    print('Python package missing — run gradle assemblePyPackage')\n    raise","preventionTips":["Always run 'gradle assemblePyPackage' as part of your build before launching.","Set MODULE_HOME / MODULE_<NAME>_HOME to the correct module root in launch scripts.","Verify the pypkg/src subtree exists in distributed installs."],"tags":["python","build","environment","gradle","ghidra-debug"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}