ATH-MaaS/Pixelle-Video · error · RuntimeError
dashscope package not installed. Run: pip install dashscope
Error message
dashscope package not installed. Run: pip install dashscope
What it means
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.
Source
Thrown at pixelle_video/services/api_services/vlm_dashscope.py:53
images: List[str],
model: str,
stream: bool = False,
parameters: Optional[Dict] = None,
videos: Optional[List[str]] = None,
**kwargs
) -> Any:
"""
使用阿里云 dashscope SDK 进行多模态对话(文本+图片/视频),风格与 image_dashscope.py 一致。
:param text: 文本内容
:param images: 图片路径列表(支持本地路径或URL,内部会转换为file://绝对路径)
:param videos: 视频路径列表(支持本地路径或URL,内部会转换为file://绝对路径)
:param model: 模型名(支持qwen3.5-plus, qwen3-vl-plus)
:param stream: 是否流式输出(暂不支持流式)
:param parameters: 其他API参数
:return: API响应内容 dict
"""
if dashscope is None or MultiModalConversation is None:
raise RuntimeError("dashscope package not installed. Run: pip install dashscope")
dashscope.api_key = self.api_key
# 只支持非流式
try:
content = [
{"text": text},
*({"image": p} for p in images),
*({"video": p} for p in videos or []),
]
messages = [{"role": "user", "content": content}]
response = MultiModalConversation.call(
model=model,
messages=messages,
api_key=self.api_key,
enable_thinking=False,
**(parameters or {})
)
if hasattr(response, 'status_code') and response.status_code == 200:View on GitHub (pinned to 848b054e4f)
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.
Example fix
# before $ python service.py RuntimeError: dashscope package not installed. Run: pip install dashscope # after $ pip install dashscope $ python service.py # chat() proceeds and calls MultiModalConversation.call(...)
Defensive patterns
Strategy: validation
Validate before calling
try:
import dashscope
from dashscope import MultiModalConversation
DASHSCOPE_READY = True
except ImportError:
DASHSCOPE_READY = False
if not DASHSCOPE_READY:
raise SystemExit("Install deps first: pip install dashscope") Type guard
def dashscope_available() -> bool:
try:
import dashscope # noqa: F401
from dashscope import MultiModalConversation # noqa: F401
return True
except ImportError:
return False Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- HTML rendering failed: {type(e).__name__}: {e}
- API media service is not initialized
- Progress must be between 0.0 and 1.0, got {self.progress}
- Image edit failed: {response.code}, {response.message}, stat
- DASHSCOPE_API_KEY 未设置,无法使用图片上传服务
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/2635fdc610df11be.
Report an issue: GitHub.