Skip to content
Advertisement

pyinstaller makes an empty black window of my tkinter gui

For a very simple example, consider the following code

JavaScript

which produces a window like so:

enter image description here

After running pyinstaller --onefile --noconsole minimal.py (the name of the code file is minimal.py), I obtain, in the dist folder a bundle file (the app) which, when run, gives me the following:

enter image description here

The menu works just normally (that’s the reason for which I included it; it’s not really minimal, but it shows that something’s working…), but none of the widgets in the window are visible (not to mention the black color of the window, which I suppose is related to the problem).

It also happens that when I double click the app icon to open it, it tries to open it (the icon shows up in the dock bar for a second), and then it opens it for good after two seconds, more or less; this also doesn’t seem normal.

What should I do? Thanks

Advertisement

Answer

As I’ve started with Python through Jupyter (respectively Anaconda) but also had python installed through homebrew I ran into a similar issue as described by the OP. Meaning tkinter windows show fine through python interpreter but as soon as I created an executable with pyinstaller some of the windows just had wrong colors (all text was white for example).

I found this topic: Using pyinstaller with anaconda environment talking about it so went with:

JavaScript

but that didn’t really make pyinstaller work so I went to look further and uninstalled pyinstaller which I installed through pip and installed it through conda

JavaScript

I then tried to run stuff but I got some issue with external packages. So I checked pip list which didn’t show the packages anymore. Infact pip version shows something like this:

JavaScript

Not ideal :-D But after “pip installing” the packages that were missing, the windows started to show just fine after creating the executables with pyinstaller.

I guess if you run into this issue, you might just have a conflict of different python versions?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement