ffpyplayer ImportError:导入播放器时DLL加载失败

Posted

技术标签:

【中文标题】ffpyplayer ImportError:导入播放器时DLL加载失败【英文标题】:ffpyplayer ImportError: DLL load faileld while importing player 【发布时间】:2021-05-21 10:14:20 【问题描述】:

我正在使用 python3.8 在 Windows 10 上工作。我想安装 ffpyplayer 模块,并使用以下命令:

python3 -m pip install --upgrade ffpyplayer

似乎没有问题。但是,当我尝试运行 `from ffpyplayer.player import MediaPlayer.它返回以下错误

from ffpyplayer.player import MediaPlayer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File 
"C:\Users\g\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\ffpyplayer\player\__init__.py", line 10, in <module>
from ffpyplayer.player.player import MediaPlayer
ImportError: DLL load failed while importing player: The specified module could not be found.

为什么它可以在一个实例中导入,而不能在下一个实例中导入?是什么导致第二个示例中的导入错误?

【问题讨论】:

您是否按照matham.github.io/ffpyplayer/installation.html 安装了先决条件?我的怀疑是直接导入 MediaPlayer 会触发一些尝试加载 DLL 的代码来执行。不存在的 DLL 会引发错误。我的怀疑是您的系统上没有安装 ffmpeg 二进制文件。 @XtrmJosh 感谢您的快速回复。我可以问一下 pip install ffpyplayer 命令是否应该安装那些 ffmpeg 二进制文件?我认为网站上的“编译”部分只是在您不想通过 pip install 命令安装它的情况下。老实说,对此的任何澄清都会非常非常有帮助。 【参考方案1】:

ffpyplayer 构建 ffmpeg 包含路径如下: _ffmpeg = join(sys.prefix, 'share', 'ffpyplayer', 'ffmpeg', 'bin')

sys.prefix 解析为 Python 安装目录,例如C:\Program Files\Python.

如果ffpyplayer不是在CMD管理员模式下使用PIP安装的,则该软件包将安装到用户本地%AppData%\Python目录中。这就是 ffmpeg 没有按预期解决的原因。

解决方案:

pip 卸载 ffpyplayer CMD(管理员模式) 点安装 ffpyplayer

【讨论】:

【参考方案2】:

我回答了一个类似的问题,但基本上是在您的规范文件中导入 ffpyplayer 并将 ffpyplayer.dep_bins 添加到您的树中,如下所示:

*[Tree(p) for p in (source1 + source2 + ffpyplayer.dep_bins)]

https://***.com/a/70392062/16355112

【讨论】:

还有更多工作要做。在另一个答案中,我发布了完整的内容,但是您需要在您的规范文件中添加所有 ffpyplayer 依赖项:datas = ['ffpyplayer', 'ffpyplayer.pic','ffpyplayer.threading', 'ffpyplayer.tools', 'ffpyplayer.writer','ffpyplayer.player', 'ffpyplayer.player.clock', 'ffpyplayer.player.core', 'ffpyplayer.player.decoder', 'ffpyplayer.player.frame_queue', 'ffpyplayer.player.player', 'ffpyplayer.player.queue'] 然后使用python -m pip uninstall kivy.deps.gstreamer 卸载 gstreamer,一旦您编译 ffpyplayer 应该可以工作

以上是关于ffpyplayer ImportError:导入播放器时DLL加载失败的主要内容,如果未能解决你的问题,请参考以下文章

使用 OpenCV 和 ffpyplayer 进行音视频同步

ImportError:导入 PCA 时无法导入名称“LatentDirichletAllocation”[关闭]

ImportError:无法导入名称“评估”(来自意外导入评估)

ImportError:无法导入名称发现

ImportError:无法导入名称“AFAVSignature”

ImportError:无法导入名称 VarianceThreshold