Skip to content

Packaging

TomSchimansky edited this page Mar 22, 2022 · 4 revisions

Windows PyInstaller (Auto Py to Exe)

When you create a .exe on Windows with pyinstaller, there are two things you have to consider. Firstly, you cannot use the --onefile option of pyinstaller, because the customtkinter library includes not only .py files, but also data files like .json and .otf. PyInstaller is not able to pack them into a single .exe file, so you have to use the `--onedir´ option.

And secondly, you have to include the customtkinter directory manually with the --add-data option of pyinstaller. Because for some reason, pyinstaller doesn't automatically include datafiles like .json from the library. You can find the install location of the customtkinter library with the following command:

pip show customtkinter

Then you get a location, for example: c:\users\<usern_ame>\appdata\local\programs\python\python310\lib\site-packages Then you can add the library folder like this: --add-data "C:/Users/test4/AppData/Local/Programs/Python/Python310/Lib/site-packages/customtkinter;customtkinter/"

With Auto Py to Exe you would do it like this:

Bildschirmfoto 2022-03-22 um 19 47 32

For the full command you get something like this:

pyinstaller --noconfirm --onedir --windowed --add-data "<CustomTkinter Location>/customtkinter;customtkinter/"  "<Path to Python Script>"

⚠️ Attention ⚠️

The Github Wiki is outdated, the new documentation can be found at:

https://customtkinter.tomschimansky.com

Clone this wiki locally