使用conda env在Mac上的PyCharm中运行时,“ffmpy”找不到“ffmpeg”

2024-10-02 02:42:48 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在conda环境中的MacOS Catalina上运行PyCharm中的以下代码时:

import ffmpy

ff = ffmpy.FFmpeg(
     inputs={'download/v_5c80f6ac3e28a_7BumyNgu/video.m3u8': ['-protocol_whitelist', 'crypto,file,http,https,tcp,tls']},
     outputs={'download/ffmpy_test.mp4': None}
)
print(ff.cmd)
ff.run()

我得到了这个错误:

Traceback (most recent call last):
  File "/Users/myname/.conda/envs/xiaoetong/lib/python3.7/site-packages/ffmpy.py", line 95, in run
    stderr=stderr
  File "/Users/myname/.conda/envs/xiaoetong/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/Users/myname/.conda/envs/xiaoetong/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myname/Documents/Projects/xiaoetong/ffmpy_test.py", line 8, in <module>
    ff.run()
  File "/Users/myname/.conda/envs/xiaoetong/lib/python3.7/site-packages/ffmpy.py", line 99, in run
    raise FFExecutableNotFoundError("Executable '{0}' not found".format(self.executable))
ffmpy.FFExecutableNotFoundError: Executable 'ffmpeg' not found

Process finished with exit code 1

上面的回溯信息字面上意味着ffmpeg未安装或命令未添加到路径。然而,我确实安装了它,并且我可以在终端中成功地调用ffmpeg命令。我甚至可以在完全相同的conda环境中(并使用完全相同的python解释器)在zsh终端中运行该python脚本而不会出错

(一些可能有用的信息:

  1. 同样的代码也可以在Windows 10上PyCharm的同一conda环境中无误运行。

  2. python==3.7.5,ffmpeg==4.2,ffmpy==0.2.2)

这个错误太奇怪了,我一点都不知道。请有人帮忙,我会很感激的


Tags: runinpy环境liblinecondausers

热门问题