ttkbootstrap not working with pyinstaller

Viewed 1110

With Python Interpreter it works fine, image loads and main.py runs without problems, but when I make it into one file .exe with Pyinstaller, .exe crashes with the following error message.

FileNotFoundError: 'themes.json' resource not found in 'ttkboostrap'

Any help would be sincerely appreciated.

4 Answers

Had the same issue.

Head over to where your ttkbootstrap is installed, copy themes.json and Symbola.ttf (if required) to the same folder as your main.py and main.spec.

Then modify your main.spec with datas=[('themes.json', 'ttkbootstrap'), ('Symbola.ttf', 'ttkbootstrap')] under a = Analysis().

Symbola.ttf may not be required for you but I encountered another FileNotFoundError after copying themes.json over to the folder, which required me to bring over Symbola.ttf as well.

Once done, run pyinstaller main.spec on elevated command prompt.

In your.spec file change as follows

datas=[('venv\Lib\site-packages\ttkbootstrap', 'ttkbootstrap')],

hiddenimports=['ttkbootstrap']

important - check in ttkbootstrap FOLDER available in in your venv\Lib\site-packages

then run pyinstaller -F your.spec

I faced the same issue.

Try using the old version of ttkbootstrap.Version "0.5.2" worked in my case.

Without changing .spec file simply add this command:

pyinstaller --onefile --windowed main.py --collect-all ttkbootstrap
Related