简体   繁体   English

ModuleNotFoundError:尽管 Anaconda 导航器上安装了 ffmpeg,但 Spyder 上没有名为“ffmpeg”的模块

[英]ModuleNotFoundError: No module named 'ffmpeg' on Spyder although ffmpeg is installed on Anaconda navigator

ffmpeg 安装在 Anaconda Navigator 上(在base(root)<\/code>环境中),但是当我运行import ffmpeg<\/code> ,我收到以下错误消息:

ModuleNotFoundError: No module named 'ffmpeg'

I'm no expert but this thread on GitHub explains that anaconda installs FFmpeg as a script that can be run but not as a package you can import .我不是专家,但GitHub 上的这个帖子解释说 anaconda 将 FFmpeg 安装为可以运行的脚本,但不能作为可以import的包。 As such you need to note the path of the FFmpeg.exe for your anaconda environment + build the commands and pass them to the subprocess module, which you do need to import.因此,您需要记下 anaconda 环境的 FFmpeg.exe 路径 + 构建命令并将它们传递给您确实需要导入的subprocess进程模块。 So, building on a SO questions like this one , to compress a video (for example), a Windows command in python might look something like:因此,建立一个SO问题,像这一个,来压缩视频(例如),Python中的Windows命令可能看起来像:

import subprocess
pathFFmpeg = r'C:\Users\YOURNAME\anaconda3\envs\ENVNAME\Scripts\ffmpeg.exe'
pathInput = r'C:\Videos\mybigvideo.mp4'
pathOutput = r'C:\Videos\mysmallervideo.mp4'
commands_list = [
    pathFFmpeg,
    "-i", pathInput,
    "-c:v", "libx265",
    "-preset", "fast",
    "-crf", "22",
    "-c:a", "aac",
    "-b:a", "196k",
    "-pix_fmt", "yuv420p", pathOutput
    ]    
results = subprocess.run(commands_list)
if results.returncode==0:
    print ("FFmpeg Script Ran Successfully")
else:
    print ("There was an error running your FFmpeg script")

试试这个以使用 pip 命令将 FFmpeg 安装为 python 库

pip install ffmpeg

You need to install the ffmpeg-python module to the environment:您需要将 ffmpeg-python 模块安装到环境中:

pip install ffmpeg-python

or或者

conda install -c conda-forge ffmpeg-python

from there import ffmpeg statements when using the environment should work.使用环境时从那里import ffmpeg语句应该可以工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:anaconda spyder 中没有名为“pyLDAvis”的模块 - ModuleNotFoundError: No module named 'pyLDAvis' in anaconda spyder 安装在 Anaconda 中的模块,与 Spyder 相同的解释器,但 Spyder 得到“ModuleNotFoundError” - Module installed in Anaconda, same interpreter with Spyder yet Spyder gets “ModuleNotFoundError” ModuleNotFoundError:尽管已安装,但没有名为“moviepy”的模块 - ModuleNotFoundError: No module named 'moviepy' although installed ModuleNotFoundError:没有名为“PyDIP”的模块,尽管它已安装 - ModuleNotFoundError: No module named 'PyDIP', although it's installed ModuleNotFoundError:虽然安装了 Django 中没有名为“moviepy”的模块 - ModuleNotFoundError: No module named 'moviepy' in Django although installed ModuleNotFoundError:在anaconda 3,spyder中未发生名为“ sklearn”的模块错误 - ModuleNotFoundError: No module named 'sklearn' error occurred in anaconda 3, spyder 如果在 anaconda 提示符下运行没有问题,但是 ModuleNotFoundError: No module named &#39;keras&#39; in Spyder - It's OK if run in anaconda prompt but ModuleNotFoundError: No module named 'keras' in Spyder ModuleNotFoundError:即使在Windows PC中使用anaconda成功安装了opencv库之后,在Spyder IDE中也没有名为“ cv2”的模块 - ModuleNotFoundError: No module named 'cv2' in Spyder IDE, even after I have successfully installed opencv library using anaconda in my windows pc ModuleNotFoundError:spyder 中没有名为“pip”的模块 - ModuleNotFoundError: No module named 'pip' in spyder 在 Spyder ModuleNotFoundError 中:没有名为“plotly”的模块 - in Spyder ModuleNotFoundError: No module named 'plotly'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM