Trying to include 3 files which are used in the script scriptName
.
JSON file.
Driver file.
Logo icon
Tried to do it with --add-data
but this option is for non-code use files.
So I tried spec
file.
##specName.py##
block_cipher = None
added_files =
[
( 'jsonfile.json', '.D:\\Directory\\jsonfile'),
( 'logo1.ico', '.D:\\Directory\\logo1'),
( 'chromedriver.exe', '.D:\\Directory\\chromedriver')
]
a = Analysis(['gui.pyw'],
pathex=['D:\\Pyton\\...\\scriptName'],
binaries=[],
datas=added_files,
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,
exclude_binaries=True,
name='MyExcutable.exe',
debug=False,
strip=False,
upx=True,
console=False, icon='D:\\Pyton\\...\\logo1.ico' )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='gui')
finaly--pyi-build specName.spec
then right after making one executable file
pyinstaller.exe --onefile --windowed --icon=logo1.ico scriptName.py
EDITED By the way, on the script I'm using this function for relative path -
def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath("."), relative_path)
(It gets the orignial path)
But the exe does not work. Any ideas?