[Solution] Pyinstaller UnicodeDecodeError: 'utf-8' codec can't decode byte

(Comments)

[Solution] Pyinstaller UnicodeDecodeError: 'utf-8' codec can't decode byte

Issue Description

scipy version: 0.19.1

OS: Windows

Python 3.5

pyInstaller version: 3.2.1

To reproduce the issue, create a python file

scipy_test.py

from scipy import special
print(special)

In the same directory run the command

pyinstaller --onefile -c -a -y --clean scipy_test.py --debug > output.txt

It will generate this error


...
return exec_command(*cmdargs, **kwargs)
File "c:\users\hasee\appdata\local\programs\python\python35\lib\site-packages\PyInstaller\compat.py", line 356, in exec_command
out = out.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 151: invalid continuation byte

Solution

Navigate to PyInstaller directory, in my case

C:\Users\hasee\AppData\Local\Programs\Python\Python35\Lib\site-packages\PyInstaller

PyInstaller

First remove the __pycache__ folder, it contains some precompiled python file we are going to modify

Change python35\lib\site-packages\PyInstaller\compat.py, line 356 into this which handels the exception.

            try:
                out = out.decode(encoding)
            except:
                out = os.fsdecode(out)

That it, run the pyInstaller command and it should work!

Current rating: 1.8

Comments