3

I have a python code which runs perfectly and I compiled it using py_compile.compile. The compile operation also worked nicely without any errors.

However, when I use this pyc file I get an error like

File "E:/tech/tech.pyc", line 1
    SyntaxError: Non-ASCII character '\xf3' in file E:/tech/tech.pyc on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

My question is how do I debug this error? The first line in my script is import os. I tried using

#!/usr/bin/python

It does not help either. Any suggestions on how this can be debugged?

3
  • Do you have any 'accent' characters in there at all, in any comments? Commented Apr 4, 2014 at 11:13
  • Did you try adding the encoding as per PEP 0263 Commented Apr 4, 2014 at 11:15
  • Apparently you handle Unicode characters in some routines that can handle only ASCII. Commented Apr 4, 2014 at 11:30

1 Answer 1

2

You're doing something wrong. Please show your code. '\xf3' looks a lot like the pyc magic number to me (assuming you're using python 2.7):

>>> import imp
>>> imp.get_magic()
'\x03\xf3\r\n'

Are you trying to compile a pyc file (as if it were python source code)?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.