{"record":{"id":"2635fdc610df11be","repo":"ATH-MaaS/Pixelle-Video","slug":"dashscope-package-not-installed-run-pip-install-2635fd","errorCode":null,"errorMessage":"dashscope package not installed. Run: pip install dashscope","messagePattern":"dashscope package not installed\\. Run: pip install dashscope","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/vlm_dashscope.py","lineNumber":53,"sourceCode":"        images: List[str],\n        model: str,\n        stream: bool = False,\n        parameters: Optional[Dict] = None,\n        videos: Optional[List[str]] = None,\n        **kwargs\n    ) -> Any:\n        \"\"\"\n        使用阿里云 dashscope SDK 进行多模态对话（文本+图片/视频），风格与 image_dashscope.py 一致。\n        :param text: 文本内容\n        :param images: 图片路径列表（支持本地路径或URL，内部会转换为file://绝对路径）\n        :param videos: 视频路径列表（支持本地路径或URL，内部会转换为file://绝对路径）\n        :param model: 模型名（支持qwen3.5-plus, qwen3-vl-plus）\n        :param stream: 是否流式输出（暂不支持流式）\n        :param parameters: 其他API参数\n        :return: API响应内容 dict\n        \"\"\"\n        if dashscope is None or MultiModalConversation is None:\n            raise RuntimeError(\"dashscope package not installed. Run: pip install dashscope\")\n\n        dashscope.api_key = self.api_key\n        # 只支持非流式\n        try:\n            content = [\n                {\"text\": text},\n                *({\"image\": p} for p in images),\n                *({\"video\": p} for p in videos or []),\n            ]\n            messages = [{\"role\": \"user\", \"content\": content}]\n            response = MultiModalConversation.call(\n                model=model,\n                messages=messages,\n                api_key=self.api_key,\n                enable_thinking=False,\n                **(parameters or {})\n            )\n            if hasattr(response, 'status_code') and response.status_code == 200:","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/vlm_dashscope.py#L35-L71","documentation":"QwenVLClient.chat() guards its dependency at the top of the call: the module imports dashscope and MultiModalConversation inside a try/except ImportError and sets them to None on failure. When either is None, chat() raises RuntimeError telling the developer to install the dashscope package. This means the SDK was never installed (or failed to import) in the current Python environment.","triggerScenarios":"Calling QwenVLClient.chat() (directly or via query()) in an environment where `pip install dashscope` was never run, where it was installed into a different virtualenv/interpreter than the one running the code, or where the installed dashscope version lacks MultiModalConversation so the import fails and both names are set to None.","commonSituations":"Fresh clone without installing requirements; running the service under a different venv/conda env than where deps were installed; deployment containers missing the dependency; an old/broken dashscope wheel that fails to import.","solutions":["Run `pip install dashscope` in the same interpreter/venv that runs pixelle_video (e.g. `python -m pip install dashscope`).","Verify with `python -c \"import dashscope; from dashscope import MultiModalConversation; print(dashscope.__version__)\"`.","If using a virtualenv/conda, activate it before launching the service, or reinstall deps inside the deployment image.","Ensure requirements.txt / Dockerfile includes dashscope so fresh environments get it."],"exampleFix":"# before\n$ python service.py\nRuntimeError: dashscope package not installed. Run: pip install dashscope\n# after\n$ pip install dashscope\n$ python service.py  # chat() proceeds and calls MultiModalConversation.call(...)","handlingStrategy":"validation","validationCode":"try:\n    import dashscope\n    from dashscope import MultiModalConversation\n    DASHSCOPE_READY = True\nexcept ImportError:\n    DASHSCOPE_READY = False\n\nif not DASHSCOPE_READY:\n    raise SystemExit(\"Install deps first: pip install dashscope\")","typeGuard":"def dashscope_available() -> bool:\n    try:\n        import dashscope  # noqa: F401\n        from dashscope import MultiModalConversation  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":null,"preventionTips":["Pin dashscope in requirements.txt and install before launching the service.","Run the service with the same interpreter where deps are installed (check `which python` / `sys.executable`).","Add a startup health check that imports dashscope and fails fast.","In Docker, ensure `pip install dashscope` runs in the same image/layer used at runtime."],"tags":["python","missing-dependency","dashscope","runtime-error"],"backgroundTag":"missing-dependency","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}