IBM / ibmi-oss-issues

Important resources for anyone interested in open source on IBM i
Creative Commons Zero v1.0 Universal
13 stars 0 forks source link

IBMi error: SyntaxError: Non-UTF-8 code starting with '\x89' #17

Closed Rene-DZ closed 2 years ago

Rene-DZ commented 2 years ago

I am getting an error when I run it on the IBMi prod: Python 3.9.11 python dbqrys.py
SyntaxError: Non-UTF-8 code starting with '\x89' in file /home/rdro01/dbqrys.py on line 1, but no encoding declared; see https:// python.org/dev/peps/pep-0263/ for details
$
but if i run it on DEV Python 3.6.12 the same program, it works fine. any idea why it does not work with Python 3.9.11?

kadler commented 2 years ago

My guess is your script got copied to production in EBCDIC instead of ASCII. 0x89 is not a valid character in UTF-8 or ISO-8859-1 (ie CCSID 819), but is i in EBCDIC which seems likely since the first line of the script is probably something like import foo.

Make sure the contents of your script is in UTF-8 (or set the appropriate encoding line from PEP-263)