{"record":{"id":"2aaf210aed8c485e","repo":"calesthio/OpenMontage","slug":"python-module-module-name-r-not-installed-self","errorCode":null,"errorMessage":"Python module {module_name!r} not installed. {self.install_instructions}","messagePattern":"Python module (.+?) not installed\\. (.+?)","errorType":"exception","errorClass":"DependencyError","httpStatus":null,"severity":"error","filePath":"tools/base_tool.py","lineNumber":325,"sourceCode":"            if dep.startswith((\"cmd:\", \"binary:\")):\n                prefix = \"cmd:\" if dep.startswith(\"cmd:\") else \"binary:\"\n                cmd_name = dep[len(prefix):]\n                if shutil.which(cmd_name) is None:\n                    raise DependencyError(\n                        f\"Command {cmd_name!r} not found. {self.install_instructions}\"\n                    )\n            elif dep.startswith(\"env:\"):\n                env_name = dep[4:]\n                if not os.environ.get(env_name):\n                    raise DependencyError(\n                        f\"Environment variable {env_name!r} not set. {self.install_instructions}\"\n                    )\n            elif dep.startswith(\"python:\"):\n                module_name = dep[7:]\n                try:\n                    __import__(module_name)\n                except ImportError:\n                    raise DependencyError(\n                        f\"Python module {module_name!r} not installed. {self.install_instructions}\"\n                    )\n\n    def get_info(self) -> dict[str, Any]:\n        \"\"\"Return full tool contract info for registry/discovery.\"\"\"\n        usage_location = inspect.getfile(self.__class__)\n        return {\n            \"name\": self.name,\n            \"version\": self.version,\n            \"tier\": self.tier.value,\n            \"capability\": self.capability,\n            \"provider\": self.provider,\n            \"stability\": self.stability.value,\n            \"status\": self.get_status().value,\n            \"execution_mode\": self.execution_mode.value,\n            \"determinism\": self.determinism.value,\n            \"runtime\": self.runtime.value,\n            \"module_path\": self.__class__.__module__,","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/base_tool.py#L307-L343","documentation":"Raised by BaseTool.check_dependencies when a dependency declared with the python: prefix fails to import. The tool does __import__(module_name) and converts ImportError into DependencyError with the module name and install_instructions. Note the check imports the top-level module only; a module that imports but lacks a required sub-dependency can pass this check and fail later.","triggerScenarios":"A tool declaring e.g. 'python:whisper' or 'python:moviepy' running in an environment where the package is not installed, installed under a different interpreter (pip vs pip3, another venv), or shadowed by a broken install that raises ImportError.","commonSituations":"Virtualenv not activated in the running process; the package installed with --user for a different Python minor version; a partially corrupted site-packages entry; name shadowing by a local file with the same module name.","solutions":["Install the package into the interpreter that runs the tool: python -m pip install <module>","Verify with the same interpreter: python -c \"import <module>\"","If a local file shadows the module name, rename it","Confirm the venv is active in the process that executes the tool (services often need absolute venv paths)"],"exampleFix":"# before\nresult = tool.run(inputs)  # DependencyError: Python module 'moviepy' not installed\n\n# after (same interpreter as the tool run)\n# python -m pip install moviepy\nresult = tool.run(inputs)","handlingStrategy":"validation","validationCode":"for d in tool.dependencies:\n    if d.startswith(\"python:\"):\n        try:\n            __import__(d[7:])\n        except ImportError:\n            raise SystemExit(f\"install {d[7:]} into this interpreter: python -m pip install {d[7:]}\")\n# or: assert tool.check_available() is ToolStatus.AVAILABLE","typeGuard":"def tool_python_modules_importable(tool) -> bool:\n    for d in tool.dependencies:\n        if d.startswith(\"python:\"):\n            try:\n                __import__(d[7:])\n            except ImportError:\n                return False\n    return True","tryCatchPattern":"from tools.base_tool import DependencyError\ntry:\n    tool.check_dependencies()\nexcept DependencyError as e:\n    if \"Python module\" in str(e):\n        run(\"python -m pip install \" + extract_module(e))\n        tool.check_dependencies()  # re-verify\n    raise","preventionTips":["Install tool dependencies with the same interpreter that runs the tools (python -m pip)","Activate the venv (or use absolute venv paths) in services and cron","Avoid local files shadowing dependency module names"],"tags":["dependencies","python","installation","virtualenv"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}