Moviepy OSError Exec format error - Missing Shebang?
<p>I am attempting to use MoviePy with Python 3.2.3 on Raspian.
I have installed it (for Python 2.7, 3.2 and 3.5... long story) and the line</p>

<pre><code>from moviepy.editor import *
</code></pre>

<p>works fine.
When I try</p>

<pre><code>clip = VideoFileClip("vid.mov")
</code></pre>

<p>which is the most basic command, it gives the error</p>

<pre><code>Traceback (most recent call last):
File "/home/pi/QuickFlicsPics/moviepytest.py", line 8, in &lt;module&gt;
  clip = VideoFileClip("vid.mov")
File "/usr/local/lib/python3.2/distpackages/moviepy/video/io/VideoFileClip.py", line 55, in __init__
  reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
File "/usr/local/lib/python3.2/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 32, in __init__
   infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
File "/usr/local/lib/python3.2/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 237, in ffmpeg_parse_infos
  proc = sp.Popen(cmd, **popen_params)
File "/usr/lib/python3.2/subprocess.py", line 745, in __init__
  restore_signals, start_new_session)
File "/usr/lib/python3.2/subprocess.py", line 1371, in _execute_child
  raise child_exception_type(errno_num, err_msg)

OSError: [Errno 8] Exec format error
</code></pre>

<p>I have researched this error, and it appears to be something to do with a shebang line missing somewhere. Is this correct, if so, how do I go about finding where it is missing, and what do I add?
Thanks</p>

<p>Edit:
As per cxw's comment, I installed moviepy using the command</p>

<pre><code>pip-3.2 install moviepy
</code></pre>

<p>(I may have used 'sudo' as well)</p>

<p>FFMPEG was supposed to download automatically when I first used moviepy:</p>

<blockquote>
  <p>MoviePy depends on the software FFMPEG for video reading and writing. > You donât need to worry about that, as FFMPEG should be automatically > downloaded/installed by ImageIO during your first use of MoviePy (it takes a few seconds). If you want to use a specific version of FFMPEG, follow the instructions in file config_defaults.py.</p>
</blockquote>

<p>[Quote from installation guide <a href="https://zulko.github.io/moviepy/install.html" rel="nofollow">here</a>]</p>

<p>Manually download ffmpeg, then before running your Python code, do</p>

<pre><code>export FFMPEG_BINARY=path/to/ffmpeg
</code></pre>

<p>at the shell/terminal prompt.</p>

<p>As far as I can tell from <a href="https://github.com/imageio/imageio/blob/master/imageio/plugins/ffmpeg.py#L48" rel="nofollow">the source</a>, the automatic download of ffmpeg does not know about Raspberry Pis.  The <a href="https://github.com/imageio/imageio/blob/master/imageio/core/fetching.py#L29" rel="nofollow">auto-download code</a> pulls from <a href="https://github.com/imageio/imageio-binaries/tree/master/ffmpeg" rel="nofollow">the imageio github repo</a>, which only knows "linux32" vs. "linux64".  It doesn't look like it has an ARM-linux option.  When the ARM kernel sees a non-ARM image, it throws the error you see.</p>

<p>Rather than using the environment variable, you can edit your moviepy <a href="https://github.com/Zulko/moviepy/blob/master/moviepy/config_defaults.py" rel="nofollow"><code>config-defaults.py</code></a> file to specify <code>FFMPEG_BINARY = r"/path/to/ffmpeg"</code>.</p>

<p><strong>Edit</strong> to find the <code>path/to/ffmpeg</code> after installing it with <code>apt-get</code>, do</p>

<pre><code>dpkg -L ffmpeg | grep bin
</code></pre>

<p>at the shell/terminal prompt.  It will probably be in <code>/bin</code> or <code>/usr/bin</code>, and will probably be called <code>ffmpeg</code> or <code>ffmpeg-x.xx</code> (with some version number).<br>
<sub>Thanks to <a href="http://askubuntu.com/a/129024">this answer</a> for <code>dpkg</code></sub></p>

python linux python-3.x raspberry-pi moviepy