Python Forum
'No module named tkinter.messagebox' - PyInstaller
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'No module named tkinter.messagebox' - PyInstaller
#1
I suspect I won't get an answer but i'll try regardless...

Compiling my script (pyinstaller) and running the .exe results in:
No module named tkinter.messagebox
When the interpreter will run the script JUST FINE with 0 errors whatsoever.

The script import statement:
import tkinter.messagebox as tkmb
I say this every time i write python:
It shouldn't be this difficult to actually implement a finished product. If you can't compile your code you've produced nothing!

Thanks for any help/ideas.
Reply
#2
https://pyinstaller.readthedocs.io/en/st...wrong.html

add --hidden-import so that pyinstaller can find it

(Jan-18-2020, 09:31 PM)ironfelix717 Wrote: If you can't compile your code you've produced nothing!
you would be surprised that many/most of python programs run without being compiled to executable
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Hi thanks for your reply..

OK hidden imports seemed to fix that, apparently pyinstaller has 0 intelligence - thus i'm going to have to include every single module as one of these 'hidden imports'. I don't know the syntax and the documentation is overly complex.

My current syntax is: (for one file)
pyinstaller -y -F --hidden-import tkinter.messagebox  "//Mac/Home/Desktop/App/InstallerV2.py
Any ideas how to include multiple modules in this command?

P.S. pyinstaller is disappointing...
Reply
#4
(Jan-18-2020, 09:59 PM)ironfelix717 Wrote: P.S. pyinstaller is disappointing...
actually it's one of the best and easiest to use. documentation is excellent. never mind...

either add --hiden-import option for each module it can't find or better edit the generated spec file. then use the edited spec file to create the executabale
And the reason it can not find them is in the packages - it's explaiend in the link I provided
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Hi, thanks... I am debugging now.

My issue is that modules are in Sys.Path.

PyInstaller can't find them from Sys.Path? Not a good design.
Reply
#6
instead of:
Quote:import tkinter.messagebox as tkmb
I import like so:
from tkinter.messagebox import *
with no issues with pyinstaller, you'll have modify your code, the proper way would name the message box directly without the wildcard.
Reply
#7
importing with an asterisk is lousy in my opinion for the fact that you now are
not really aware of what library you're using a method from.
Its not clear what module 'messagebox' is from when you use it in code.

Regardless, PyInstaller should have no issues finding modules.
Everything is in Sys.Path. Its basically that simple.

The next issue i just ran into when attempting to execute the .exe on
a barebones system is that it failed to execute EVEN when it ran fine
on my development system. CMD output says can't find a module. How can
i even rely on this tool?

Programs are meant to be compiled and if its that difficult to compile
an interpreted language like Python then i'll consider forgetting the language
as its mostly useless in actually implementing an actual program.

Forgive my irritable mood. Thanks for the help.
Reply
#8
(Jan-19-2020, 01:14 AM)ironfelix717 Wrote: importing with an asterisk is lousy in my opinion for the fact that you now are
not really aware of what library you're using a method from.
Its not clear what module 'messagebox' is from when you use it in code.
100% agree. Star imports are bad and should be avoided

You don't provide much information about the modules it cannot find. Are you manipulating sys.path in the code? Try to extend search path by adding --paths
https://pyinstaller.readthedocs.io/en/st...g-the-path

also you can get more verbose messages
https://pyinstaller.readthedocs.io/en/st...g-messages
https://pyinstaller.readthedocs.io/en/st...g-the-path
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 850 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 23,618 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,511 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,419 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,483 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,311 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,020 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,892 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 994 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  Tkinter messagebox WiPi 4 2,027 Dec-10-2022, 09:19 AM
Last Post: WiPi

Forum Jump:

User Panel Messages

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