PyInstaller 3.6
Python 2.7.16
Windows 10
I'm trying to bundle a Python executable into a single directory that can then be zipped and exported to other Windows 10 machines. I've been building the tool via pyinstaller XLHDiagnosticTool.spec
using the following spec file:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['XLHDiagnosticTool.py'],
pathex=['C:\Users\snathan\xl-service-diagnostic-tool\DiagnosticToolCodeBase','C:Python27Libsite-packages'],
binaries=[],
datas=[
('DBCs/','DBCs'),
('SignalLists/','SignalLists'),
('FaultIDListing.xlsx','.')
],
hiddenimports=['canlib','kvadblib'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='XLHDiagnosticTool',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='XLHDiagnosticTool')
The resulting executable runs properly on the Windows 10 machine that compiled it, but when I zip the bundled directory, copy it to another Win 10 machine, and try to run it there, it fails with the following error:
C:UserssnathanDesktopXLHDiagnosticTool>XLHDiagnosticTool.exe
Traceback (most recent call last):
File "XLHDiagnosticTool.py", line 20, in <module>
File "c:userssnathanappdatalocalemppip-unpacked-wheel-lmq204PyInstallerloaderpyimod03_importers.py", line 391, in load_module
File "convertRawLog.py", line 4, in <module>
File "c:userssnathanappdatalocalemppip-unpacked-wheel-lmq204PyInstallerloaderpyimod03_importers.py", line 391, in load_module
File "DBCparser.py", line 1, in <module>
File "c:userssnathanappdatalocalemppip-unpacked-wheel-lmq204PyInstallerloaderpyimod03_importers.py", line 391, in load_module
File "canlibkvadblib\__init__.py", line 9, in <module>
File "c:userssnathanappdatalocalemppip-unpacked-wheel-lmq204PyInstallerloaderpyimod03_importers.py", line 391, in load_module
File "canlibkvadblibattribute.py", line 6, in <module>
File "c:userssnathanappdatalocalemppip-unpacked-wheel-lmq204PyInstallerloaderpyimod03_importers.py", line 391, in load_module
File "canlibkvadblibwrapper.py", line 82, in <module>
File "canlibdllLoader.py", line 147, in load_dll
WindowsError: [Error 2] The system cannot find the file specified
[10704] Failed to execute script XLHDiagnosticTool
The error seems to be that it can't find the dllLoader.py file in the canlib package directory. canlib and kvadblib packages aren't imported in the main XLHDiagnosticTool.py file, they're imported in another python file that XLHDiagnosticTool.py calls. I've tried accounting for this by specifying the site-packages folder to look in as well as specifying that the canlib and kvadblib libraries be hidden-imports, but the problem still crops up. The issue is compounded by the fact that the problem only appears on some computers the tool is run on but not others.
question from:
https://stackoverflow.com/questions/65837013/pyinstaller-executable-cannot-find-necessary-import-canlib-dllloader-py