Reputation: 189
I created an exe file using the below spec file in --onedir
mode. The folder got created successfully under dist
folder. I could see the requirements in the onedir folder ROY
.
# -*- mode: python -*-
block_cipher = None
a = Analysis(['C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python37-32\\final.py'],
pathex=['C:\\Users\\****'],
binaries=[('bg.png', 'bg.png')],
datas=[('C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages', 'ttkthemes')],
hiddenimports=['ttkthemes'],
hookspath=[],
runtime_hooks=[],
excludes=['scipy'],
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='final',
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,
name='final')
Upon executing the exe file getting the below error:
Traceback (most recent call last):
File "final.py", line 1043, in <module>
File "final.py", line 40, in __init__
File "site-packages\ttkthemes\themed_tk.py", line 43, in __init__
File "site-packages\ttkthemes\_widget.py", line 72, in __init__
File "site-packages\ttkthemes\_widget.py", line 78, in _load_themes
_tkinter.TclError: couldn't read file "themes/pkgIndex.tcl": no such file or directory
pkgIndex.tcl
does exist under themes
folder. Should I treat ttkthems
specially in the spec
file? Should I add any hooks?
Kindly help me resolve this!
Upvotes: 1
Views: 876
Reputation: 491
Instead of importing the entire site-packges
folder, import only the ttkthemes
folder. I have updated the datas
and binaries
. Using images
will create a folder named images
under the main --onedir
folder (final
), you can also provide any other name. According to your code, it will create a folder named bg.png
inside the final
folder.
The syntax would be binaries = [(file_name,destination_folder), (file_name,destination_folder)]
you can add as many files as you need.
# -*- mode: python -*-
block_cipher = None
a = Analysis(['C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python37-32\\final.py'],
pathex=['C:\\Users\\****'],
binaries=[('bg.png', 'images')],
datas=[('C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages\\ttkthemes', 'ttkthemes')],
hiddenimports=['ttkthemes'],
hookspath=[],
runtime_hooks=[],
excludes=['scipy'],
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='final',
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,
name='final')
Upvotes: 1