首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法安装moviepy

无法安装moviepy
EN

Stack Overflow用户
提问于 2022-07-07 05:24:30
回答 1查看 110关注 0票数 0

首先,我在终端中输入了以下命令来安装必要的软件包:

代码语言:javascript
复制
pip install moviepy
pip install ffmpeg

然后,当我试图运行以下代码时,我得到了以下内容:

代码语言:javascript
复制
from moviepy.editor import *

错误: RuntimeError:找不到ffmpeg exe。在系统上安装ffmpeg,或者设置IMAGEIO_FFMPEG_EXE环境变量。

为了修复错误,我在前面的代码行上输入了以下代码:

代码语言:javascript
复制
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg"
from moviepy.editor import *

这解决了我之前遇到的问题,并且我能够导入它。在代码中键入的位置是在我键入时直接从location属性的输出中复制的,在终端中显示ffmpeg。但是,当我实际尝试使用这个库时,会发现以下错误:

代码语言:javascript
复制
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg"
from moviepy.editor import *

clip = VideoFileClip("master_video.mp4") 
代码语言:javascript
复制
Error: 
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
Input In [2], in <cell line: 5>()
      2 os.environ["IMAGEIO_FFMPEG_EXE"] = "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg"
      3 from moviepy.editor import *
----> 5 clip = VideoFileClip("master_video.mp4") 
      7 for x in range(0,10):
      8     print(randint(0, 2420))

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/io/VideoFileClip.py:88, in VideoFileClip.__init__(self, filename, has_mask, audio, audio_buffersize, target_resolution, resize_algorithm, audio_fps, audio_nbytes, verbose, fps_source)
     86 # Make a reader
     87 pix_fmt = "rgba" if has_mask else "rgb24"
---> 88 self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
     89                                  target_resolution=target_resolution,
     90                                  resize_algo=resize_algorithm,
     91                                  fps_source=fps_source)
     93 # Make some of the reader's attributes accessible from the clip
     94 self.duration = self.reader.duration

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py:35, in FFMPEG_VideoReader.__init__(self, filename, print_infos, bufsize, pix_fmt, check_duration, target_resolution, resize_algo, fps_source)
     33 self.filename = filename
     34 self.proc = None
---> 35 infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
     36                            fps_source)
     37 self.fps = infos['video_fps']
     38 self.size = infos['video_size']

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py:257, in ffmpeg_parse_infos(filename, print_infos, check_duration, fps_source)
    254 if os.name == "nt":
    255     popen_params["creationflags"] = 0x08000000
--> 257 proc = sp.Popen(cmd, **popen_params)
    258 (output, error) = proc.communicate()
    259 infos = error.decode('utf8')

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:969, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
    965         if self.text_mode:
    966             self.stderr = io.TextIOWrapper(self.stderr,
    967                     encoding=encoding, errors=errors)
--> 969     self._execute_child(args, executable, preexec_fn, close_fds,
    970                         pass_fds, cwd, env,
    971                         startupinfo, creationflags, shell,
    972                         p2cread, p2cwrite,
    973                         c2pread, c2pwrite,
    974                         errread, errwrite,
    975                         restore_signals,
    976                         gid, gids, uid, umask,
    977                         start_new_session)
    978 except:
    979     # Cleanup if the child failed starting.
    980     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:1845, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
   1843     if errno_num != 0:
   1844         err_msg = os.strerror(errno_num)
-> 1845     raise child_exception_type(errno_num, err_msg, err_filename)
   1846 raise child_exception_type(err_msg)

PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg'

提前谢谢你

EN

回答 1

Stack Overflow用户

发布于 2022-07-07 05:40:28

在python中使用ffmpeg似乎并不容易,所以我建议您安装一个包,比如凤尾巨蟒。如果您坚持使用ffmpeg,那么请遵循提到的这里的解决方案。这避免了您的第二个问题,该问题源于将环境路径设置为文件夹,然后尝试打开文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72892657

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档