alejandroautalan / pygubu

A simple GUI builder for the python tkinter module
MIT License
2.01k stars 213 forks source link

Run executable file by pyinstaller generated, the erroe showed “ModuleNotFoundError: No module named 'Notebook'” #270

Closed 1893945 closed 1 year ago

1893945 commented 1 year ago

Hi, when I Run executable file by pyinstaller generated, the erroe showed “ModuleNotFoundError: No module named 'Notebook'”. error tip:

[<class 'ModuleNotFoundError'>] No module named 'Notebook'

Traceback (most recent call last): File "pygubu\builder.py", line 193, in _import_class File "importlib__init__.py", line 127, in import_module File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'ttk'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "pygubu\builder.py", line 201, in _import_class File "importlib__init__.py", line 127, in import_module File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'ttk'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tktools.py", line 235, in File "tktools.py", line 28, in init File "pygubu\builder.py", line 167, in get_object File "pygubu\builder.py", line 215, in _realize File "pygubu\builder.py", line 204, in _import_class File "importlib__init__.py", line 127, in import_module File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'Notebook'

File "tktools.py", line 28 code is: self.mainwindow = builder.get_object("notebook1", master)

this is the minimum example. see the attach files: tk_tools.zip

pyinstaller --add-data "tools2.ui;." -D tktools2.py

pygubu 0.25 pygubu-designer 0.30 pyinstaller 5.4.1 pyinstaller-hooks-contrib 2022.10

note: I debugged and found that it seemed to be PluginManager.py "for , name, in iter_namespace(pygubu.plugins):" not executed, when run exe file.

so, How should I deal with this problem?

thanks

alejandroautalan commented 1 year ago

Hello @1893945 thanks for trying pygubu.

I tried to reproduce the error but I couldn't.

OS: Windows 10 Python: Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32 pyinstaller==5.4.1 pyinstaller-hooks-contrib==2022.10 pygubu==0.25 pygubu-designer==0.30

With your example:

pyinstaller --add-data "tools2.ui;." -D tktools2.py

Running the executable, no error is shown.

2022-09-13_22-25

What python version are you using?

Regards Alejandro A.

1893945 commented 1 year ago

Python 3.8.10

1893945 commented 1 year ago

your build/tktool2/PYZ-00.toc file have pygubu.plugins.* ?

1893945 commented 1 year ago

When I run pyinstaller, system show: WARNING: discover_hook_directories: Failed to process hook entry point 'hook-dirs = pygubu.__pyinstaller:get_hook_dirs': TypeError: 'type' object is not subscriptable

I run pygubu/pyinstaller/init__.py: image

alejandroautalan commented 1 year ago

Oh, I will try with your python version.

In the meantime, can you test if it works with a spec file similar to this one ?

Regards Alejandro A.

1893945 commented 1 year ago

OK, It is valid to use spec file

1893945 commented 1 year ago

Great!