{"record":{"id":"4406e46779ed0566","repo":"HKUDS/DeepTutor","slug":"dashscope-sdk-not-installed-run-pip-install-dash","errorCode":null,"errorMessage":"dashscope SDK not installed. Run `pip install dashscope` (or add to your project deps) to enable Aliyun DashScope.","messagePattern":"dashscope SDK not installed\\. Run `pip install dashscope` \\(or add to your project deps\\) to enable Aliyun DashScope\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/embedding/adapters/dashscope_native.py","lineNumber":107,"sourceCode":"        params: Dict[str, Any] = {}\n        dim_value = request.dimensions or self.dimensions\n        if dim_value:\n            params[\"dimension\"] = dim_value\n        return params\n\n    async def embed(self, request: EmbeddingRequest) -> EmbeddingResponse:\n        model_name = request.model or self.model\n        if is_dashscope_multimodal_embedding_model(model_name):\n            return await self._embed_multimodal(request, model_name)\n        return await self._embed_text(request, model_name)\n\n    async def _embed_multimodal(\n        self, request: EmbeddingRequest, model_name: str\n    ) -> EmbeddingResponse:\n        try:\n            from dashscope import MultiModalEmbedding\n        except ImportError as exc:\n            raise ImportError(\n                \"dashscope SDK not installed. Run `pip install dashscope` \"\n                \"(or add to your project deps) to enable Aliyun DashScope.\"\n            ) from exc\n\n        contents = self._build_contents(request)\n        parameters = self._build_parameters(request)\n\n        logger.debug(\n            \"Calling dashscope.MultiModalEmbedding.call \"\n            f\"(model={model_name}, items={len(contents)}, params={parameters})\"\n        )\n\n        # SDK call is sync — run in worker thread to avoid blocking the loop.\n        # IMPORTANT: the dashscope SDK takes a flat list for `input`\n        # (e.g. ``input=[{\"text\": \"...\"}]``) and internally wraps it as\n        # ``{\"contents\": [...]}`` before POSTing to the REST endpoint. Do NOT\n        # pass ``{\"contents\": contents}`` here — that produces a double-wrap\n        # and the API responds with HTTP 400 (\"Input should be a valid list\").","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/embedding/adapters/dashscope_native.py#L89-L125","documentation":"The multimodal path of the DashScope adapter imports dashscope.MultiModalEmbedding lazily and converts ImportError into a helpful ImportError with install instructions. dashscope is an optional dependency, only required when actually using Aliyun DashScope multimodal embeddings.","triggerScenarios":"Configuring the dashscope embedding provider with contents in the request and calling embed() in an environment where the dashscope package is absent.","commonSituations":"Slim deployment images excluding the optional extra; new envs provisioned from a trimmed requirements list; venvs created before the multimodal feature was enabled.","solutions":["pip install dashscope (or add to project deps / the relevant extras group)","Switch to a provider whose SDK is already installed if DashScope isn't actually needed"],"exampleFix":"# before\nImportError: dashscope SDK not installed...\n# after\npip install dashscope\n# requirements.txt: dashscope>=1.20","handlingStrategy":"validation","validationCode":"try:\n    import dashscope  # noqa: F401\n    dashscope_ok = True\nexcept ImportError:\n    dashscope_ok = False\n\nif request.contents and not dashscope_ok:\n    raise ImportError(\"install dashscope before using multimodal embeddings\")","typeGuard":null,"tryCatchPattern":"try:\n    await adapter.embed(req)\nexcept ImportError as e:\n    if \"dashscope\" in str(e):\n        subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"dashscope\"])\n        return await adapter.embed(req)\n    raise","preventionTips":["Include optional SDKs in deployment dependency checks","Surface capability flags from a startup doctor probe"],"tags":["dashscope","optional-dependency","import-error","embeddings"],"backgroundTag":"missing-optional-dependency","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}