python - Moviepy OSError Exec 格式错误 - 缺少 Shebang?

标签 python linux python-3.x raspberry-pi moviepy

我正在尝试在 Raspian 上将 MoviePy 与 Python 3.2.3 结合使用。 我已经安装了它(适用于 Python 2.7、3.2 和 3.5……长话短说)和行

from moviepy.editor import *

工作正常。 当我尝试

clip = VideoFileClip("vid.mov")

这是最基本的命令,它给出了错误

Traceback (most recent call last):
File "/home/pi/QuickFlicsPics/moviepytest.py", line 8, in <module>
  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

我研究了这个错误,它似乎与某处缺少的 shebang 行有关。这是正确的吗?如果是这样,我该如何找到它丢失的地方,我应该添加什么? 谢谢

编辑: 根据 cxw 的评论,我使用命令安装了 moviepy

pip-3.2 install moviepy

(我可能也用过'sudo')

当我第一次使用 moviepy 时,FFMPEG 应该会自动下载:

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.

[引自安装指南here ]

最佳答案

手动下载 ffmpeg,然后在运行 Python 代码之前执行

export FFMPEG_BINARY=path/to/ffmpeg

在 shell/终端提示符下。

据我所知 the source ,ffmpeg的自动下载不知道树莓派。 auto-download code拉取自 the imageio github repo ,它只知道“linux32”与“linux64”。看起来它没有 ARM-linux 选项。当 ARM 内核看到非 ARM 镜像时,它会抛出您看到的错误。

除了使用环境变量,您还可以编辑您的 moviepy config-defaults.py文件以指定 FFMPEG_BINARY = r"/path/to/ffmpeg"

编辑,找到path/to/ffmpeg,用apt-get安装后,执行

dpkg -L ffmpeg | grep bin

在 shell/终端提示符下。它可能在 /bin/usr/bin 中,并且可能被称为 ffmpegffmpeg-x.xx(带有一些版本号)。
感谢this answer对于 dpkg

关于python - Moviepy OSError Exec 格式错误 - 缺少 Shebang?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40004639/

相关文章:

linux - 在 Raspberry Pi 上安装 NPM bmp085 模块时出错

python - 使用 Tweepy 和 MySQL 未引发的异常

python - 如何从 Django 的两列中获取最新的时间戳

python - 如何在Python中将数组与其数组元素合并?

python - 在 Python 中自动检测 C/C++ 循环并放置大括号

arrays - bash:如何删除函数内的列表条目?

linux - Android SDK在Eclipse上调试问题

python - PyAudio:如何以回调/非阻塞模式访问 stream.read() 数据

python - 为什么程序中的列表会给出意外的输出?

python - 将列表中的每个项目加倍