2

I'm trying to package a python script which uses python-vlc using pyinstaller, but the resulting .exe refuses to recognize the libvlc.dll binary file. I always get the same error:

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!

Which seems to be a problem others have fixed by including either binary or data files in the spec file. Nothing I add to the spec file makes any difference, though. Here's where it is now, I've even included Windows system dlls that the VLC one depends on:

# -*- 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')

All the files listed under binaries do indeed appear in the dist folder, so I don't think it's a formatting issue. I'm using 32-bit versions of both Python and VLC. Is there anything else I can try before giving up?

Windows 11, Python 3.8.8, pyinstaller 4.9

zchrywht
  • 51
  • 2

0 Answers0