How to Install MoviePy in CI Without ffmpeg/ImageMagick Errors
MoviePy edits video through external tools: ffmpeg for encoding and ImageMagick for text clips. CI fails at runtime when those binaries are missing, not at pip install.
MoviePy is a Python video-editing library that delegates the heavy lifting to ffmpeg (read/write/encode) and, for TextClip/captions, to ImageMagick. The pip install succeeds without them, so failures surface at runtime: ffmpeg not found for video work, ImageMagick not found for text.
Why it fails in CI
MoviePy shells out to ffmpeg for almost all video operations and to ImageMagick’s convert for text rendering. A slim runner has neither, so reading/writing video raises an ffmpeg error and TextClip raises an ImageMagick error. Fonts are also needed for legible text.
This command failed ... ffmpeg/ ffmpeg binary not found when writing video.TextCliperror - ImageMagick (convert) not installed.- ImageMagick policy blocks the temp operations
TextClipuses.
Install it reliably
Install ffmpeg (video) and ImageMagick (text), plus fonts, via apt, then pip install MoviePy. For TextClip you may also need to relax the ImageMagick policy in the CI image.
# Debian/Ubuntu: ffmpeg (video) + ImageMagick (TextClip) + fonts
apt-get update && apt-get install -y ffmpeg imagemagick fonts-liberation
pip install moviepy
# TextClip blocked by ImageMagick policy? relax it (CI only):
# sed -i 's/rights="none" pattern="@\*"/rights="read|write" pattern="@*"/' \
# /etc/ImageMagick-6/policy.xmlCache & speed
ffmpeg and ImageMagick are system binaries - bake them into a custom image. Cache ~/.cache/pip for the Python packages. Video encoding is CPU-heavy, so size the runner accordingly.
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-moviepy-${{ hashFiles('requirements*.txt') }}Common errors
| Error | Cause | Fix |
|---|---|---|
| ffmpeg command failed / not found | No ffmpeg binary | apt-get install ffmpeg |
| TextClip error | No ImageMagick | apt-get install imagemagick |
| ImageMagick policy blocks TextClip | Restrictive policy.xml | Relax policy (CI only) |
| Boxed/blank text | No fonts | apt-get install fonts-liberation |
Key takeaways
- MoviePy needs ffmpeg (video) and ImageMagick (TextClip) - install both.
- pip install passes; failures surface at runtime on slim images.
- Skip ImageMagick if you do not render text clips.