Python Forum
Problems with PyInstaller with tkinter app on python 3.5
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with PyInstaller with tkinter app on python 3.5
#1
Just getting started with Pyinstaller (and somewhat with Tk windowing) and having trouble getting my tkinter windows app (under python 3.5.3) running successfully. I may be doing something stupid but I've tried everything I know and I really need to get this running, so any help is greatly appreciated.  Just a note, all of my code runs fine under normal python 3.5.1 & 3.5.3. Have latest version of PyInstaller installed (3.2.1) and it appears to be running OK. I also tried the latest development version of PyInstaller (3.3) but it gave the same issues.

I switched over to the following simple windowed "Hello World!" app to see if I could get this to work,

   from tkinter import *
   root = Tk()
   root.title("Test Window")
   
   #Setup window widgets and place on window
   l1 = Label(root,text='Hello World!',font=("Verdana",18))
   l2 = Label(root,text='Hello World!',font=("Times New Roman",9))
   b1 = Button(root, text='Button 1', font=("Verdana",12), state=DISABLED)
   b1.pack()
   b1.place(x=220, y=180)
   
   l1.pack()
   l1.place(x=170, y=10)
   l2.place(x=200, y=60)
   
   root.mainloop()
but it appears to be having the same issues as my original application.  

Maybe it's just because I'm new to PyInstaller but I'm not finding the docs really easy to find specific answers from.  But looking a little deeper, I decided to add the -d option to the command line to see the debug output as it tried to execute my app, so the complete command line I'm using is: > pyinstaller -F -w -d c:\PythonApps\Hello.py . That gave me lots of info (but nothing really helpful at this point) ending in this error message:

Failed to execute script pyi_rth_tkinter.

I was able to find 'pyi_rth_tkinter.py' on my system (actually 2 versions of the file), not sure why PyInstaller is having problems executing it.  But since that file spits out error messages about path problems for Tcl & Tk data directories, guessing it would have failed on that anyway even if it had found & ran the file.  

OK, looking more closely at the output during the running of PyInstaller, I see that there are a few lines that look like they may be leading to my problem:

Error:
3541 INFO: Loading module hook 'hook-_tkinter.py' ImportError: cannot import name 'Tcl' 3659 ERROR: Tcl/Tk improperly installed on this system.
I looked at the "hook-_tkinter.py" hook file (and read through the PyInstaller docs) but didn't see anything obviously amiss.  But I'm not fully aware of all the details of the hook files and exactly what they need to contain (can anyone help with this???). Not exactly sure what the problem is but it appears PyInstaller is having an issue with linking into tkinter and that is causing my app(s) not to run. HAS ANYONE GOTTEN PyInstaller 3.2.1 TO EXECUTE EVEN A SIMPLE PYTHON 3.5 WINDOWS APP?  IF SO, PLEASE SHARE HOW!  I've done a ton of searching and reading but have not been able to uncover what the problem is yet.  If anyone has a clue, please help.  Any guidance is greatly appreciated!

A bit of additional info.  Not sure why PyInstaller is saying Tcl/Tk is not properly installed. I just installed Python 3.5.3 and tkinter was installed automatically.  Executed 'tkinter._text()' in a shell and it appears to work fine.  All my uses of tkinter also appear to work fine under all versions of 3.5 under normal use of python. Only tkinter problem I'm having is with PyInstaller.  Verified the exact version of Tcl/Tk installed with 'tkinter.Tcl().eval('info patchlevel')' and it reported '8.6.4'.  Does anyone know of any other installation issues with Tcl/Tk that may be a problem?  I did not do anything special to install tkinter, I just did a normal install of pyinstaller via 'pip install pyinstaller' after doing a fresh install of 'python 3.5.3'. Was there anything else I should have done?  Any help is greatly appreciated!!!
Reply


Messages In This Thread
Problems with PyInstaller with tkinter app on python 3.5 - by sealyons - Jun-14-2017, 02:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python - pyinstaller Hyster 0 289 Mar-05-2025, 07:11 PM
Last Post: Hyster
  Pyinstaller and a custom python script mentat 0 941 Sep-27-2024, 04:42 PM
Last Post: mentat
  Pyinstaller 3 Python 2 mckymntl 0 1,769 Feb-07-2022, 06:28 AM
Last Post: mckymntl
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 8,483 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable kmarien 3 4,936 Nov-30-2020, 04:10 PM
Last Post: buran
  'No module named tkinter.messagebox' - PyInstaller ironfelix717 7 11,356 Jan-19-2020, 06:56 AM
Last Post: buran
  Cannot Change Python script to exe using Pyinstaller omar_mohsen 3 3,217 Dec-19-2019, 01:05 PM
Last Post: buran
  Problems running exe file from pyinstaller ersa21 4 9,435 Jan-15-2019, 06:36 PM
Last Post: snippsat
  Error with using pyinstaller to convert python script in Mac OS Takeshio 2 6,431 Oct-19-2018, 02:42 PM
Last Post: Takeshio
  compiling python using pyinstaller sabeesh90 0 3,285 Aug-16-2018, 09:58 AM
Last Post: sabeesh90

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020