【问题标题】:EXE made with PyInstaller can't load libvlc.dll (python-vlc)使用 PyInstaller 制作的 EXE 无法加载 libvlc.dll (python-vlc)
【发布时间】:2022-12-19 23:44:06
【问题描述】:

我正在尝试使用 pyinstaller 打包一个使用 python-vlc 的 python 脚本,但生成的 .exe 拒绝识别 libvlc.dll 二进制文件。我总是得到同样的错误:

Traceback (most recent call last):
  File "ctypes\__init__.py", line 381, in __init__
OSError: [WinError 193] %1 is not a valid Win32 application

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "vlc-test.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "vlc.py", line 210, in <module>
  File "vlc.py", line 170, in find_lib
  File "PyInstaller\loader\pyimod04_ctypes.py", line 55, in __init__
pyimod04_ctypes.PyInstallerImportError: Failed to load dynlib/dll '.\\libvlc.dll'. Most likely this dynlib/dll was not found when the application was frozen.
[2236] Failed to execute script 'vlc-test' due to unhandled exception!

这似乎是其他人通过在规范文件中包含二进制文件或数据文件来解决的问题。不过,我添加到规范文件中的任何内容都没有任何区别。这是现在的位置,我什至包含了 VLC 所依赖的 Windows 系统 dll:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(['vlc-test.py'],
             pathex=["D:\\GitHub\\hours", "C:\\Users\\zacha\\anaconda3\\envs\\hours\\Lib\\site-packages"],
             binaries=[("C:\\Program Files (x86)\\VideoLAN\\VLC\\libvlc.dll","."),
                ("C:\\Program Files (x86)\\VideoLAN\\VLC\\libvlccore.dll","."),
                ("C:\\Program Files (x86)\\VideoLAN\\VLC\\axvlc.dll","."),
                ("C:\\Program Files (x86)\\VideoLAN\\VLC\\npvlc.dll","."),
                ("C:\\Windows\\SysWOW64\\advapi32.dll","."),
                ("C:\\Windows\\SysWOW64\\kernel32.dll","."),
                ("C:\\Windows\\SysWOW64\\MSVCRT.dll","."),
                ],
             datas=[('./libvlc.dll', '.'), ('./axvlc.dll', '.'), ('./libvlccore.dll', '.'), ('./npvlc.dll', '.')],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

a.datas += Tree("C:\\Program Files (x86)\\VideoLAN\\VLC\\plugins", prefix='plugins')
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz,
          a.scripts, 
          [],
          exclude_binaries=True,
          name='vlc-test',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas, 
               strip=False,
               upx=True,
               upx_exclude=[],
               name='vlc-test')

二进制文件下列出的所有文件确实出现在 dist 文件夹中,所以我认为这不是格式问题。我正在使用 32 位版本的 Python 和 VLC。在放弃之前还有什么我可以尝试的吗?

Windows 11、Python 3.8.8、pyinstaller 4.9

【问题讨论】:

    标签: python pyinstaller vlc python-vlc


    【解决方案1】:

    我对 dynlib/dll 有类似的错误。你解决了吗?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-03
    • 2018-07-13
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多