Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyinstaller error
#1
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?
Larz60+ write Jun-04-2022, 10:42 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please plase error message in bbcode error tags.
Reply
#2
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.
Reply
#3
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
Reply
#4
The error message refers to the imported modulegraph.
Reply
#5
Yes, but modlulegraph is part of pyinstaller, not part of my application. That is why I posted my request for help in this forum.
Reply
#6
If you don't need modulegraph you can exclude it in pyinstaller.
Reply
#7
Thank you.
I have decided to move on from trying to use pyinstaller.
Reply
#8
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,398 Jun-27-2023, 01:17 PM
Last Post: diver999
  Pyinstaller to exe error Tyrel 3 1,807 Aug-26-2021, 06:54 AM
Last Post: buran
  error SimpleITK module with pyinstaller PythonCode12 0 1,607 Jul-08-2020, 12:07 PM
Last Post: PythonCode12
  Pyinstaller create this error :“File ”multiprocessing\connection.py“, line 691 Formationgrowthhacking 2 3,644 Apr-30-2020, 10:26 AM
Last Post: buran
  Error ' Attribute error: 'str' object has no attribute 'items'' in pyinstaller manhnt 2 8,943 Nov-04-2018, 05:51 PM
Last Post: Larz60+
  Error with using pyinstaller to convert python script in Mac OS Takeshio 2 5,393 Oct-19-2018, 02:42 PM
Last Post: Takeshio
  pyinstaller error aquilino67 3 6,211 Feb-21-2018, 11:18 PM
Last Post: aquilino67

Forum Jump:

User Panel Messages

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