2

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.

TheLizzard
  • 7,248
  • 2
  • 11
  • 31

4 Answers4

3

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.

Wen Hao
  • 46
  • 3
  • Thank you for answering. I'm not sure as to what you mean by "run `pyinstaller main.spec` on elevated command prompt". Should I run this command after running `pyinstaller main.py` or before? – Sumon Kumar Jun 30 '21 at 11:08
  • 1
    Hi there, no need to run `pyinstaller main.py` at all, just run `pyinstaller main.spec` will do because what the `.spec` file will do is that it will instruct Pyinstaller on how to process your script with `a = Analysis(['main.py'], ...)`. More details here https://pyinstaller.readthedocs.io/en/stable/spec-files.html – Wen Hao Jul 01 '21 at 12:26
2

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

0

I faced the same issue.

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

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 16 '22 at 01:35
0

Without changing .spec file simply add this command:

pyinstaller --onefile --windowed main.py --collect-all ttkbootstrap
benson23
  • 16,369
  • 9
  • 19
  • 38