This is my error message when I run the compiled exe. Error message
I am running python in a pyenv with 3.9.13. I can run the python project, but when I compile it with PyInstaller, there seems to be dependency issues.
The PyInstaller is ran from the same environment, as I make sure to use the command
python -m PyInstaller main.spec
.
The spec file is as follows:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['Scripts\\main.py'],
pathex=['C:\\Users\\Bruker\\Documents\\System'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
Tree('Classes\\Database', prefix=''),
Tree('Classes\\Simulator', prefix=''),
Tree('Classes\\Simulator\\DataStorage', prefix=''),
Tree('Classes\\Simulator\\Window, Camera and GUI', prefix=''),
a.zipfiles,
a.datas,
name='system',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False, icon='res\\logo.ico')
I just find it confusing as to why the exe file would not work as it's generated from the same environment.
Any suggestions?
If anyone else has this issue, it is due to the binaries for GLFW. In order to fix this, add the binaries to the spec file. To find the binaries, use this code.
# Import the necessary PyInstaller hooks
from PyInstaller.utils.hooks import collect_dynamic_libs
# Specify the binaries in the spec file
binaries = collect_dynamic_libs('glfw')
# Print the binaries to copy
print(binaries)
Copy these binaries into the spec file and it should work.