Non-UTF-8 code starting with '\xff' when when running setup.py

Viewed 4397

I'm following Python's Packaging Projects tutorial and when it tells to run python3 setup.py sdist bdist_wheel I receive the following error:

PS C:\Users\username\dev\packaging_tutorial> python setup.py sdist
 bdist_wheel
  File "setup.py", line 1
SyntaxError: Non-UTF-8 code starting with '\xff' in file setup.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

I have no idea why I get this error since my setup.py file is identical to theirs. Has anyone had the same problem?

1 Answers

You are getting this error since the file is created with the default encoding type of powershell, Windows-1252. You'll have to change the encoding type of the file to UTF-8, which python can recognize as python executable. You can achieve this by using the command chcp 65001

Related