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



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

python3 -m pip install --upgrade ffpyplayer

似乎没有问题。在PowerShell中使用python并声明import ffpyplayer不返回任何东西,然而,当我尝试从ffpyplayer运行时。导入MediaPlayer。它返回以下错误

from ffpyplayer.player import MediaPlayer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File 
"C:UsersgAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagesffpyplayerplayer__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.

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

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

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

如果使用PIP方式安装ffpyplayer而不是CMD管理员模式,则安装到用户本地%AppData%Python目录下。这就是ffmpeg没有按预期解析的原因。

解决方案:

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

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

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

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

work to me add this:

sudo apt-get install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config libgl1-mesa-dev libgles2-mesa-dev python-setuptools libgstreamer1.0-dev git-core gstreamer1.0-plugins-{bad,base,good,ugly} gstreamer1.0-{omx,alsa} python-dev libmtdev-dev xclip xsel

sudo apt-get install -y  ffmpeg libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libpostproc-dev libsdl2-dev libsdl2-2.0-0 libsdl2-mixer-2.0-0 libsdl2-mixer-dev python3-dev