3

I have created GUI python2.7 program with Tkinter successfully without error. Now I want to make an executable file of it using pyinstaller in anaconda environment (I'm using windows 10).

Using this command pyinstaller --onefile main.py I am able to create exe file successfully in dist folder. But when I tried to run the exe file, it showed error :

Traceback (most recent call last):   
File "main.py", line 333, in <module>   
File "main.py", line 90, in __init__   
File "lib-tk\ttk.py", line 715, in current
_tkinter.TclError: Index 0 out of range 
[22668] Failed to execute script main

Is the problem related to tkinter? I've tried the solution here : Problems with Pyinstaller with tkinter app on python 3.5 and here : How to make pyinstaller import the ttk theme? . But still same error

2
  • I would use cx_freeze to compile an exe. I have made a few projects with that library instead of pyinstaller. Commented Feb 25, 2019 at 14:21
  • Use Py-Auto-Gui for this Commented May 11, 2020 at 7:43

2 Answers 2

1

Try and do:

pyinstaller --onefile -w main.py

The -w flag stops python from bringing up the console, and so this could be why tkinter is failing.

Source: This cool video

I highly recommend you watch this video as it also goes a little in depth on how to clean up after building the exe.

Sign up to request clarification or add additional context in comments.

1 Comment

Just realized this was posted a year ago.
0

I used pyinstaller to create single exe file for a tkinter project, which contained several py files:

Main.py is my main python file which calls tkinter UI and I had several other python files imported to this Main.py. Some libraries which I used include pandas,pyodbc

Open cmd in the same directory of the project; Use following command:

pyinstaller --noconfirm --onedir --windowed --icon=XYZ.ico "C:/Users/.../Tkinter_Project/Main.py"

Application was created with no dependencies. If there is any config or image files used, simply copy paste it to the 'dist' folder which gets created.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.