[GH-ISSUE #76] UnicodeDecodeError when "import matplotlib.pyplot as plt" #74

Closed
opened 2026-02-26 12:20:23 +03:00 by kerem · 2 comments
Owner

Originally created by @datlytic on GitHub (Oct 23, 2019).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/76

When I try to compile a file with matploblib included I get the error:

----------------------------------------
'utf-8' codec can't decode byte 0x94 in position 150: invalid start byte
These are the bytes around the offending byte:
----------------------------------------
An error occurred, traceback follows:
Traceback (most recent call last):
  File "C:\Users\XXX\auto-py-to-exe-master\auto_py_to_exe\__main__.py", line 269, in convert
    pyi.run() # Execute PyInstaller
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "C:\Users\XXX\AppData\Local\Temp\tmpy60_7apn\sample.spec", line 17, in <module>
    noarchive=False)
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
    self.__postinit__()
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 502, in assemble
    module_hook.post_graph()
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
    self._load_hook_module()
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 793, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-zmq.py", line 18, in <module>
    hiddenimports = ['zmq.utils.garbage'] + collect_submodules('zmq.backend')
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 624, in collect_submodules
    repr(pkg_dir), package))
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 83, in exec_statement
    return __exec_python_cmd(cmd)
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 72, in __exec_python_cmd
    txt = exec_python(*cmd, env=pp_env)
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 637, in exec_python
    return exec_command(*cmdargs, **kwargs)
  File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 427, in exec_command
    out = out.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x94 in position 150: invalid start byte

This are the settings I use:
grafik

and this is the content of my sample.py

import time
import matplotlib.pyplot as plt

while True:
    time.sleep(1)
Originally created by @datlytic on GitHub (Oct 23, 2019). Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/76 When I try to compile a file with matploblib included I get the error: ``` ---------------------------------------- 'utf-8' codec can't decode byte 0x94 in position 150: invalid start byte These are the bytes around the offending byte: ---------------------------------------- An error occurred, traceback follows: Traceback (most recent call last): File "C:\Users\XXX\auto-py-to-exe-master\auto_py_to_exe\__main__.py", line 269, in convert pyi.run() # Execute PyInstaller File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run run_build(pyi_config, spec_file, **vars(args)) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build exec(code, spec_namespace) File "C:\Users\XXX\AppData\Local\Temp\tmpy60_7apn\sample.spec", line 17, in <module> noarchive=False) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 243, in __init__ self.__postinit__() File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__ self.assemble() File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 502, in assemble module_hook.post_graph() File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph self._load_hook_module() File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module self.hook_module_name, self.hook_filename) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 793, in importlib_load_source return mod_loader.load_module() File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper File "<frozen importlib._bootstrap_external>", line 907, in load_module File "<frozen importlib._bootstrap_external>", line 732, in load_module File "<frozen importlib._bootstrap>", line 265, in _load_module_shim File "<frozen importlib._bootstrap>", line 696, in _load File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-zmq.py", line 18, in <module> hiddenimports = ['zmq.utils.garbage'] + collect_submodules('zmq.backend') File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 624, in collect_submodules repr(pkg_dir), package)) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 83, in exec_statement return __exec_python_cmd(cmd) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 72, in __exec_python_cmd txt = exec_python(*cmd, env=pp_env) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 637, in exec_python return exec_command(*cmdargs, **kwargs) File "C:\Users\XXX\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 427, in exec_command out = out.decode(encoding) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x94 in position 150: invalid start byte ``` This are the settings I use: ![grafik](https://user-images.githubusercontent.com/38322122/67425061-99494380-f5d7-11e9-9f46-21b7fe19b933.png) and this is the content of my sample.py ``` import time import matplotlib.pyplot as plt while True: time.sleep(1) ```
kerem closed this issue 2026-02-26 12:20:24 +03:00
Author
Owner

@brentvollebregt commented on GitHub (Oct 25, 2019):

Thank you for the basic example, have you tried executing the "Current Command" yourself to see if this is PyInstaller?

I have seen other people mention this error before and it seems to be how PyInstaller decodes text files, for example pyinstaller/pyinstaller#3083.

<!-- gh-comment-id:546153769 --> @brentvollebregt commented on GitHub (Oct 25, 2019): Thank you for the basic example, have you tried executing the "Current Command" yourself to see if this is PyInstaller? I have seen other people mention this error before and it seems to be how PyInstaller decodes text files, for example pyinstaller/pyinstaller#3083.
Author
Owner

@brentvollebregt commented on GitHub (Feb 7, 2020):

Closing due to no response from @datlytic

<!-- gh-comment-id:583634184 --> @brentvollebregt commented on GitHub (Feb 7, 2020): Closing due to no response from @datlytic
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/auto-py-to-exe#74
No description provided.