ttkbootstrap not working with pyinstaller

2.9k Views Asked by At

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.

5

There are 5 best solutions below

2
On BEST ANSWER

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.

5
On

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

1
On

I faced the same issue.

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

0
On

Without changing .spec file simply add this command:

pyinstaller --onefile --windowed main.py --collect-all ttkbootstrap
0
On

Ok. I played around with this for a few minutes using pyinstaller and was able to get it to work. You need to add --collect-all ttkbootstrap

You can read more about this option here: https://pyinstaller.readthedocs.io/en/stable/usage.html

Essentially, what you need to do with either pyinstaller or py2exe is make sure that it is importing all of the required files. This can be done is various ways depending on how you are building your executable. I'm not sure if the method below is the most efficient, but it does work.

C:\\> pyinstaller yourprogram.py --collect-all ttkbootstrap

I saw this on here which worked out for me!

https://github.com/israel-dryer/ttkbootstrap/issues/43