0

First, I know similar questions have been asked but I haven't been able to find a solution to my problem. Thank you for any help!

I have been trying to create an executable using pyinstaller, and I'm having trouble getting pyinstaller to find the .dlls for libvlc. In particular: libvlc.dll and libvlccore.dll. These are in my VideoLAN\VLC directory, but I also copied all the dlls from my VideoLAN\VLC directory to my Compile directory, next to my test.py and test.spec files. I also added my VideoLAN\VLC directory to my environment variables in an attempt to help pyinstaller find them. Despite this, when I run pyinstaller test.spec I get this warning:

48352 WARNING: lib not found: libvlccore.dll dependency of C:\Users\chipc\Desktop\Code\Python\KivyTest\KivyTut\Compile\libvlc.dll

The rest of the compile log can be seen here: https://pastebin.com/DJmkQ7nm

When trying to run the generated test.exe, it gives me this:

Traceback (most recent call last):
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 149, in __init__
File "ctypes\__init__.py", line 356, in __init__
OSError: [WinError 193] %1 is not a valid Win32 application

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "c:\users\chipc\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\vlc.py", line 207, in <module>
File "site-packages\vlc.py", line 163, in find_lib
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 151, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll 'C:\\Users\\chipc\\Desktop\\Code\\Python\\KivyTest\\KivyTut\\Compile\\dist\\test\\libvlc.dll'. Most probably this dynlib/dll was not found when the application was frozen.
[16044] Failed to execute script test

In addition, the generated folder which includes test.exe does have libvlc.dll inside of it.

Here is my test.spec file:

# -*- mode: python ; coding: utf-8 -*-
from kivy_deps import sdl2, glew
block_cipher = None


a = Analysis(['test.py'],
             pathex=[('C:\\Users\\chipc\\Desktop\\Code\\Python\\KivyTest\\KivyTut\\Compile'), ('C:\Program Files\VideoLAN\VLC')],
             binaries=[('./libvlc.dll', '.'), ('./axvlc.dll', '.'), ('./libvlccore.dll', '.'), ('./npvlc.dll', '.')],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
a.datas += Tree('C:\\Program Files\\VideoLAN\\VLC\\plugins', prefix='plugins')
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='test',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe, Tree('C:\\Users\\chipc\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages\\kivy_deps'),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               name='test')

The program works in PyCharm. How can I get pyinstaller to find libvlc.dll?

Just in case, here is is what my Compile directory looks like:

axvlc.dll
libvlc.dll
libvlccore.dll
npvlc.dll
test.py
test.spec

Thanks for any help, I've been trying to figure this out for a couple of days now!

Aviolin
  • 15
  • 5
  • Maybe [this](https://stackoverflow.com/questions/56919875/error-while-running-the-exe-file-made-with-pyinstaller/56924606#56924606) can help. – Masoud Rahimi Aug 25 '19 at 03:34
  • Thanks for the reply! I had seen that post already, and I have tried using the .spec formula posted there on a very small script that simply imports vlc and time, and prints something every 3 seconds. I still get a similar error: `__main__.PyInstallerImportError: Failed to load dynlib/dll 'C:\\Users\\chipc\\AppData\\Local\\Temp\\_MEI173322\\libvlc.dll'. Most probably this dynlib/dll was not found when the application was frozen.` – Aviolin Aug 25 '19 at 05:43
  • That error means it cannot find `libvlc.dll`. On runtime open the `_MEIXXXX` directory and check if the file is there or not. – Masoud Rahimi Aug 25 '19 at 05:58
  • It looks like it does create a libVLC.dll in the _MEIXXXX directory during runtime. The directory looks like this before it crashes: _bz2 _ctypes _hashlib _lzma _socket _ssl libcrypto-1_1.dll libssl-1_1.dll libVLC.dll libvlc.dylib libvlccore.dylib VCRUNTIME140.dll – Aviolin Aug 25 '19 at 06:08
  • It is strange because you have the DLLs in the directory. Have you tried running your script directly? – Masoud Rahimi Aug 25 '19 at 06:33
  • Yeah, running `python test.py` seems to work correctly. Also, it seems strange to me that I would get a warning that libvlc.dll has a dependency (libvlccore.dll) during compile--so, it _did_ find it during compile--but then not be able to find libvlc.dll when running the exe... – Aviolin Aug 25 '19 at 06:43

0 Answers0