{"record":{"id":"5926005cad31d1b6","repo":"ATH-MaaS/Pixelle-Video","slug":"dashscope-package-not-installed-run-pip-install-592600","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/video_dashscope.py","lineNumber":177,"sourceCode":"            shot_type: 镜头类型，\"single\" 或 \"multi\"\n            video_ratio: 输出画幅比例，如 9:16 / 16:9\n            last_image_path: 可选尾帧图片本地路径（wan2.7）\n            first_clip_path: 可选首段视频本地路径（wan2.7 视频续写）\n            reference_image_path: 可选参考图片路径（videoedit）\n            reference_image_paths: 可选参考图片列表（r2v）\n            reference_video_paths: 可选参考视频列表（r2v）\n            reference_audio_path: 可选参考音频/音色路径（r2v）\n            audio_path: 可选驱动音频本地路径（wan2.7）\n\n        Returns:\n            video_url: 远端视频 URL\n\n        Raises:\n            FileNotFoundError: 输入图片不存在\n            RuntimeError: API 调用或下载失败\n        \"\"\"\n        if VideoSynthesis is None:\n            raise RuntimeError(\"dashscope package not installed. Run: pip install dashscope\")\n\n        if image_path and not os.path.exists(image_path):\n            raise FileNotFoundError(f\"输入图片不存在: {image_path}\")\n        if last_image_path and not os.path.exists(last_image_path):\n            raise FileNotFoundError(f\"尾帧图片不存在: {last_image_path}\")\n        if first_clip_path and not os.path.exists(first_clip_path):\n            raise FileNotFoundError(f\"输入视频片段不存在: {first_clip_path}\")\n        if reference_image_path and not os.path.exists(reference_image_path):\n            raise FileNotFoundError(f\"参考图片不存在: {reference_image_path}\")\n        for ref_image_path in reference_image_paths or []:\n            if ref_image_path and not os.path.exists(ref_image_path):\n                raise FileNotFoundError(f\"参考图片不存在: {ref_image_path}\")\n        for ref_video_path in reference_video_paths or []:\n            if ref_video_path and not os.path.exists(ref_video_path):\n                raise FileNotFoundError(f\"参考视频不存在: {ref_video_path}\")\n        if reference_audio_path and not os.path.exists(reference_audio_path):\n            raise FileNotFoundError(f\"参考音频不存在: {reference_audio_path}\")\n        if audio_path and not os.path.exists(audio_path):","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/video_dashscope.py#L159-L195","documentation":"The DashScope video client depends on the third-party 'dashscope' package (VideoSynthesis class). If the import failed (VideoSynthesis is None), generate_video raises RuntimeError with pip install instructions before doing anything else.","triggerScenarios":"Calling generate_video on DashScopeVideoClient when the dashscope package is not installed in the active Python environment (or the guarded import at module top failed).","commonSituations":"Fresh environment without requirements installed; wrong virtualenv activated; package installed under a different Python interpreter (system vs venv); dashscope version too old to export VideoSynthesis.","solutions":["pip install dashscope in the environment running the app","Verify with python -c \"from dashscope import VideoSynthesis; print(VideoSynthesis)\" using the same interpreter","If already installed, upgrade: pip install -U dashscope (old versions may lack VideoSynthesis)","Confirm requirements.txt includes dashscope and reinstall: pip install -r requirements.txt"],"exampleFix":"// before\nclient.generate_video(prompt)  # RuntimeError: dashscope package not installed\n// after\n# pip install dashscope\nfrom dashscope import VideoSynthesis  # now imports fine\nclient.generate_video(prompt)","handlingStrategy":"validation","validationCode":"try:\n    from dashscope import VideoSynthesis\nexcept ImportError:\n    raise SystemExit('dashscope package not installed. Run: pip install dashscope')","typeGuard":"def dashscope_available() -> bool:\n    try:\n        import dashscope\n        return hasattr(dashscope, 'VideoSynthesis')\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    video = client.generate_video(prompt)\nexcept RuntimeError as e:\n    if 'dashscope package not installed' in str(e):\n        raise SystemExit('Install dependency: pip install dashscope') from e\n    raise","preventionTips":["Pin dashscope in requirements.txt and install in the same env you run","Verify with python -c \"import dashscope\" using the active interpreter","Upgrade dashscope if VideoSynthesis is missing (old version)","Add an import smoke test to CI"],"tags":["dependency","installation","import"],"backgroundTag":"module-not-installed","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}