Python Forum
Pyinstaller error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pyinstaller error (/thread-37387.html)



Pyinstaller error - amdi40 - Jun-04-2022

Hello, I have created a program for which I want to create an exe. file for.
But I keep getting an error, and I have no clue how to fix it.
The program is made with a Tkinter GUI and uses multiple scripts, so I won't include it here as it contains over 6000 lines
The error message can be seen here:
54206 INFO: Processing pre-safe import module hook six.moves from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
69786 INFO: Processing pre-safe import module hook win32com from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.
py'.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 178, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 59, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 842, in main
build(specfile, distpath, workpath, clean_build)
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 764, in build
exec(code, spec_namespace)
File "C:\Users\Kasper Amdi Sørensen\PycharmProjects\pythonProject2\GUIPROJECT.spec", line 7, in <module>
a = Analysis(
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 319, in __init__
self.__postinit__()
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 173, in __postinit__
self.assemble()
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 481, in assemble
priority_scripts.append(self.graph.add_script(script))
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 265, in add_script
self._top_script_node = super().add_script(pathname)
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1433, in add_script
self._process_imports(n)
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2850, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2301, in _safe_import_hook
target_modules = self.import_hook(
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1505, in import_hook
target_package, target_module_partname = self._find_head_package(
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1684, in _find_head_package
target_package = self._safe_import_module(
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 387, in _safe_import_module
return super()._safe_import_module(module_basename, module_name, parent_package)
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2053, in _safe_import_module
(module, co) = self._load_module(module_name, pathname, loader)
File "C:\ProgramData\Anaconda3\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2143, in _load_module
src = loader.get_source(partname)
File "<frozen importlib._bootstrap_external>", line 906, in get_source
File "<frozen importlib._bootstrap_external>", line 688, in decode_source
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 5030: invalid start byte

Does anyone have an idea on how to fix this?


RE: Pyinstaller error - astroman133 - Sep-17-2022

I am a new Python user and have written a gui app using tkinter on Windows using Visual Studio 2022 to edit and debug the code. Now I am trying to figure out how to package the application for sharing with users.

I am trying to use pyinstaller to package the app for publishing and distribution. I get a hard error similar to the OP of this thread. Here is the last fragment from the pyinstaller output (with log-level DEBUG)

Error:
File "C:\Users\Rick\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2143, in _load_module src = loader.get_source(partname) File "<frozen importlib._bootstrap_external>", line 940, in get_source File "<frozen importlib._bootstrap_external>", line 713, in decode_source UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 5582: invalid start byte
I have uploaded a large zip file of my entire project, and the complete output from pyinstaller to the following dropbox link:

Dropbox link to project files

Any help is greatly appreciated.


RE: Pyinstaller error - astroman133 - Sep-19-2022

UPDATE: I wrote a program in C# that scanned all the text files (*.py.*.json,*.txt) in my Python project and none of the files contained non utf-8 characters.

I still need help.

Thanks!

Rick


RE: Pyinstaller error - Axel_Erfurt - Sep-19-2022

The error message refers to the imported modulegraph.


RE: Pyinstaller error - astroman133 - Sep-19-2022

Yes, but modlulegraph is part of pyinstaller, not part of my application. That is why I posted my request for help in this forum.


RE: Pyinstaller error - Axel_Erfurt - Sep-20-2022

If you don't need modulegraph you can exclude it in pyinstaller.


RE: Pyinstaller error - astroman133 - Sep-20-2022

Thank you.
I have decided to move on from trying to use pyinstaller.


RE: Pyinstaller error - Axel_Erfurt - Sep-20-2022

Pyinstaller often integrates many unnecessary modules, so you usually have to exclude modules.

In Linux, for example, it integrates all themes in Gtk apps, so that the app ends up being well over 1GB in size.

I prefer to use cxfreeze in Linux, it works better there. The app only has 30MB instead of 1GB.