2

我正在使用 Python-VLC 创建视频播放器和 PyInstaller 在我的 Windows 10 机器上生成可执行文件。最初,它给了我错误:

Import Error Failed to load dynlib/dll 'libvlc.dll'. Most probably this dynlib/dll was not found when the application was frozen.

为了解决这个问题,我通过以下方式在 .spec 文件的二进制文件中添加了缺失的 dll:

a = Analysis(['video_player.py'],
             pathex=['C:\\Users\\harsh\\Desktop\\demo\\Video'],
             binaries=[("C:\\Program Files\\VideoLAN\\VLC\\libvlc.dll","."),("C:\\Program Files\\VideoLAN\\VLC\\libvlccore.dll",".")],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

这样做之后,我不再收到上述错误。但是,现在我收到以下错误:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "threading.py", line 914, in _bootstrap_inner
  File "threading.py", line 862, in run
  File "video_player.py", line 100, in vlc_player
AttributeError: 'NoneType' object has no attribute 'media_player_new'

导致此错误的代码是:

i=vlc.Instance('--fullscreen')
p=i.media_player_new()

我已经确定我已经安装了 Python-VLC。我在这里还想念什么吗?关于如何处理这个问题的任何建议?

4

1 回答 1

0

这个问题的一个常见答案是确保您安装了 VLC 主程序,因为 vlc.py 依赖于它。而且,Python 和 libvlc.dll 都必须是 32 位的,或者都必须是 64 位的。

于 2021-02-25T21:37:08.780 回答