I have a script (hosted on DigitalOcean ubuntu 18.04.3 droplet) executing from crontab which looks something like this
0 5 * * * cd /home/john/clips/; /home/john/clips/venv/bin/python3 /home/john/clips/clip_compilator.py
And it works but once it reaches the following line inside one of the scripts
name = mp.TextClip(f"John".upper(),
color='#6441A4',
stroke_color="black",
align='West',
fontsize=90,
font='BigNoodleTitling', method='label')\
.margin(left=95, opacity=0)\
.set_position(("left", "top"))
it crashes with
Traceback (most recent call last):
File "/home/john/clips/venv/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 1161, in __init__
subprocess_call(cmd, logger=None)
File "/home/john/clips/venv/lib/python3.6/site-packages/moviepy/tools.py", line 46, in subprocess_call
proc = sp.Popen(cmd, **popen_params)
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'unset': 'unset'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/john/clips/clip_compilator.py", line 44, in <module>
current_clip.add_videofile(add_text(current_clip))
File "/home/john/clips/clip_editor.py", line 16, in add_text
fontsize=90, font='BigNoodleTitling', method='label')\
File "/home/john/clips/venv/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 1170, in __init__
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:
[Errno 2] No such file or directory: 'unset': 'unset'.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect
When I run the same command in bash (outside of the crontab) everything works fine.
For some reason it crashes on the TextClip
specifically and I don't know why.
Some have suggested the solution might be commenting out a specific line in the policy.xml
of ImageMagick but my convert -list policy
output is this:
Solved the problem by adding
from moviepy.config import change_settings
change_settings({"IMAGEMAGICK_BINARY": "/usr/local/bin/convert"})
to the top of the clip_editor.py
which had the line that was causing the error as per tomasdms's solution