[Gradio]"ModuleNotFoundError: No module named 'ffmpy'"

这篇文章我们来一起聊聊嵌入版python无法安装ffmpy(Gradio依赖)的问题

嵌入式的python虽然也是python,也能跑程序

但是作为给嵌入式系统用的免安装的环境肯定有点东西不一样,而且少了一堆内置模块

从报错内容来,问题出现在这一行

from ffmpy import __version__

具体为什么炸了,只能说是嵌入式的版本差异问题了,安装版的就没有这个毛病

解决方法也很简单

下载模块的源码包到本地,然后修改setup.py

源码包在这下:https://pypi.org/project/ffmpy/#files

加上这两行

import sys
sys.path.append('.')

此时你的setup.py看起来大概是这么个样子,注意插入上面两行的位置

from setuptools import setup
from setuptools.command.test import test as TestCommand  # noqa
import sys
sys.path.append('.')
from ffmpy import __version__

setup(
    name="ffmpy",
    version=__version__,
    description="A simple Python wrapper for ffmpeg",
    long_description=open("README.rst").read(),
    author="Andrii Yurchuk",
    author_email="[email protected]",
    license="MIT",
    url="https://github.com/Ch00k/ffmpy",
    py_modules=["ffmpy"],
    classifiers=[
        "Topic :: Multimedia :: Sound/Audio",
        "Development Status :: 4 - Beta",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Natural Language :: English",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: Python :: 3.12",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Python :: Implementation :: PyPy",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: POSIX",
        "Operating System :: POSIX :: BSD",
        "Operating System :: POSIX :: Linux",
        "Operating System :: MacOS :: MacOS X",
    ],
    keywords="ffmpeg ffprobe wrapper audio video transcoding",
)

然后,在和setup.py的同级目录下,执行这行

python setup.py

然后就装上去了,此时应该可以继续通过pip安装gradio了

点赞

赞助商广告

如果您的网络和设备条件允许,这里可能会显示来自Google和其他赞助商的广告

发表回复

电子邮件地址不会被公开。必填项已用 * 标注