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
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.
Source
Thrown at pixelle_video/services/api_services/video_dashscope.py:177
shot_type: 镜头类型,"single" 或 "multi"
video_ratio: 输出画幅比例,如 9:16 / 16:9
last_image_path: 可选尾帧图片本地路径(wan2.7)
first_clip_path: 可选首段视频本地路径(wan2.7 视频续写)
reference_image_path: 可选参考图片路径(videoedit)
reference_image_paths: 可选参考图片列表(r2v)
reference_video_paths: 可选参考视频列表(r2v)
reference_audio_path: 可选参考音频/音色路径(r2v)
audio_path: 可选驱动音频本地路径(wan2.7)
Returns:
video_url: 远端视频 URL
Raises:
FileNotFoundError: 输入图片不存在
RuntimeError: API 调用或下载失败
"""
if VideoSynthesis is None:
raise RuntimeError("dashscope package not installed. Run: pip install dashscope")
if image_path and not os.path.exists(image_path):
raise FileNotFoundError(f"输入图片不存在: {image_path}")
if last_image_path and not os.path.exists(last_image_path):
raise FileNotFoundError(f"尾帧图片不存在: {last_image_path}")
if first_clip_path and not os.path.exists(first_clip_path):
raise FileNotFoundError(f"输入视频片段不存在: {first_clip_path}")
if reference_image_path and not os.path.exists(reference_image_path):
raise FileNotFoundError(f"参考图片不存在: {reference_image_path}")
for ref_image_path in reference_image_paths or []:
if ref_image_path and not os.path.exists(ref_image_path):
raise FileNotFoundError(f"参考图片不存在: {ref_image_path}")
for ref_video_path in reference_video_paths or []:
if ref_video_path and not os.path.exists(ref_video_path):
raise FileNotFoundError(f"参考视频不存在: {ref_video_path}")
if reference_audio_path and not os.path.exists(reference_audio_path):
raise FileNotFoundError(f"参考音频不存在: {reference_audio_path}")
if audio_path and not os.path.exists(audio_path):View on GitHub (pinned to 848b054e4f)
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
Example fix
// before client.generate_video(prompt) # RuntimeError: dashscope package not installed // after # pip install dashscope from dashscope import VideoSynthesis # now imports fine client.generate_video(prompt)
Defensive patterns
Strategy: validation
Validate before calling
try:
from dashscope import VideoSynthesis
except ImportError:
raise SystemExit('dashscope package not installed. Run: pip install dashscope') Type guard
def dashscope_available() -> bool:
try:
import dashscope
return hasattr(dashscope, 'VideoSynthesis')
except ImportError:
return False Try / catch
try:
video = client.generate_video(prompt)
except RuntimeError as e:
if 'dashscope package not installed' in str(e):
raise SystemExit('Install dependency: pip install dashscope') from e
raise Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/5926005cad31d1b6.
Report an issue: GitHub.