Skip to content
Latchkey

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.
  • TextClip error - ImageMagick (convert) not installed.
  • ImageMagick policy blocks the temp operations TextClip uses.

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.

Terminal
# 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.xml

Cache & 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.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.cache/pip
    key: pip-moviepy-${{ hashFiles('requirements*.txt') }}

Common errors

ErrorCauseFix
ffmpeg command failed / not foundNo ffmpeg binaryapt-get install ffmpeg
TextClip errorNo ImageMagickapt-get install imagemagick
ImageMagick policy blocks TextClipRestrictive policy.xmlRelax policy (CI only)
Boxed/blank textNo fontsapt-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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →