I want to contribute to an open source python library which is on 2.7. (https://github.com/plexinc-plugins) Its source code files do not have this coding: utf-8
header comment that everywhere is mentioned and apparently was set in PEP 263. However, I still get an SyntaxError: Non-ASCII character 'xc3' in file […] but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
when I try to $ python
them on the command line.
(How) can I set on interpreter level, i.e. with the python
command, that the whole code base is UTF-8?
What I tried:
- I've seen environment variables (
PYTHONUTF8=1
or PYTHONIOENCODING
) that are supposed to do the trick but they don't work, i.e. error stays the same. (aha: seems to be >=3.7, so nevermind)
- A command-line argument
-X utf8
says -X is reserved for implementation-specific arguments
. (dito 3.7)
- There's also stuff going on with a
sitecustomize.py
but I don't know what it is. Is it a bootstrap file that is loaded prior to everything else? At least I wasn't able to find it.
question from:
https://stackoverflow.com/questions/65869817/define-source-code-encoding-on-command-line-not-in-source-code 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…