【问题标题】:Error when compiling python code when using ffpyplayer使用ffpyplayer时编译python代码时出错
【发布时间】:2021-08-15 19:12:38
【问题描述】:

我正在使用 pyinstaller 在 Ubunutu 上打包我的应用程序,并在我的代码中使用 import ffpyplayer。 pyinstaller 构建可执行文件,但是当我执行程序时收到此错误:

Traceback(最近一次调用最后一次):文件“hdc.py”,第 13 行,在文件中 “PyInstaller/loader/pyimod03_importers.py”,第 540 行,在 exec_module 中 文件“ffpyplayer/player/init.py”,第 10 行,在文件中 “ffpyplayer/player/player.pyx”,第 2 行,在 init ffpyplayer.player.player ModuleNotFoundError: No module named 'ffpyplayer.threading' [42447] 执行脚本 hdc 失败

我正在使用ffpyplayeropencv 来播放本地视频文件。使用 PyCharm 作为我的 IDE,ffpyplayeropencv 在 IDE 以及命令提示符下都可以完美运行。我试过 pyinstaller 有和没有 --onefile 选项,结果相同。

我该如何解决这个问题?谢谢。

【问题讨论】:

    标签: python opencv pyinstaller


    【解决方案1】:

    所以基于这个https://github.com/matham/ffpyplayer/issues/59#issuecomment-588044409

    在您的规范文件中执行:import ffpyplayer,然后在您的树行中添加:ffpyplayer.dep_bins 到列表中。如果有多个来源,您的树最终会看起来像:*[Tree(p) for p in (source1 + source2 + ffpyplayer.dep_bins)]

    编辑:您还需要添加 AND 来删除。

    您还需要添加到您的规范文件中的 datas=[] 行。这里有一个例子:https://github.com/matham/filers2/blob/master/packaging/Filers2.spec

    所以最低限度地做: 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']

    要使其正常工作,请按照以下说明卸载 gstreamer 依赖项:https://github.com/kivy/kivy/issues/6964#issuecomment-790869214 像这样:Kivy Install gone awry - Windows 10 (was working, now not after gstreamer) 在你之后python -m pip uninstall kivy.deps.gstreamer 然后用 pyinstall 再次编译,ffpyplayer 应该可以工作了

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-22
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      相关资源
      最近更新 更多