This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Installation of pyinstaller in Windows fails with utf8 error
Type: behavior Stage: resolved
Components: Installation Versions: Python 3.9
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, giomach, paul.moore, terry.reedy
Priority: normal Keywords:

Created on 2020-11-08 23:29 by giomach, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pyinstaller.txt giomach, 2020-11-08 23:29 Windows command-line log
Messages (6)
msg380564 - (view) Author: giomach (giomach) * Date: 2020-11-08 23:29
Python 3.9 freshly installed in Windows 10 to C:\Program Files\Python39, everything done as administrator, installed for all users, added to PATH.

Installation of pyinstaller fails with message "SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe1 in position 0: unexpected end of data (sitecustomize.py, line 21)" (attachment)

This may be due to the character á in my Windows username (0xe1 in ANSI, which is my default 8-bit codepage) being misinterpreted as being in utf8 instead of ANSI.

There is no sitecustomize.py in my file system.
msg380568 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2020-11-09 00:14
This looks to be a bug in the constructor of pip's BuildEnvironment class:

https://github.com/pypa/pip/blob/a4f4bfbf8ba7fd1e60884a439907e3f2a32e117a/src/pip/_internal/build_env.py#L82

Python 3 source files are UTF-8 by default, but text files default to the platform's preferred encoding, unless overridden by Python's UTF-8 mode. It is thus a mistake to create "sitecustomize.py" without explicitly specifying UTF-8 as the encoding. 

The preferred encoding in Windows is the process active code page, which is the system code page, unless, in Windows 10 only, it's overridden to use UTF-8 by the application manifest's "activeCodePage" setting. The system code page is usually a legacy code page, such as 1252, unless, in Windows 10 only, it's set to UTF-8 or the system language is Unicode only (e.g. Hindi).
msg380945 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-14 00:29
A 'crash' is when the program hangs or stops unexpectedly *without* an Exception and message.

Lib/site-packages/sitecustomize.py is an optional added module.
https://docs.python.org/3/library/site.html#index-5
Apparently, attempted installation of pyinstaller resulted in an attempt to add it.  Or it was later attempting to read a badly written file, and removed it when cleaning up.

In any case, this appears to be a 3rd party bug that should be reported on the pypa/pip tracker.  Paul, are you involved with pip?  If so, can you add anything?
msg380968 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2020-11-14 10:23
Erik is correct, this is a pip bug. Please raise an issue on the pip tracker linking to this issue and we can fix it.
msg380985 - (view) Author: giomach (giomach) * Date: 2020-11-14 19:41
I'm not sure whose responsibility it is to take this to the "pip tracker", but as a newcomer to the python environment I know nothing about that process, so it would be appreciated if some of the other people here would be kind enough to do this.
msg380991 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2020-11-14 21:22
I've raised https://github.com/pypa/pip/issues/9135 for this.
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86459
2020-11-14 21:22:46paul.mooresetmessages: + msg380991
2020-11-14 19:41:19giomachsetmessages: + msg380985
2020-11-14 10:23:33paul.mooresetmessages: + msg380968
2020-11-14 00:29:06terry.reedysetstatus: open -> closed

type: crash -> behavior

nosy: + paul.moore, terry.reedy
messages: + msg380945
resolution: third party
stage: resolved
2020-11-09 00:14:12eryksunsetnosy: + eryksun
messages: + msg380568
2020-11-08 23:29:57giomachcreate