I have a python file, [working dir/]modules/commands.py
, which contains only the following:
def getId():
return "commands"
Then I have another file, [working dir/]main.py
, which uses the following:
fpath = "modules/commands.py"
mname = "commands"
imp.load_source(mname, fpath)
After I added the getId()
to commands.py
I started getting the following error when trying to run main.py
:
SyntaxError: Non-ASCII character '\xd1' in file modules/commands.pyc on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
The error complains about non-ascii characters, but there should be none in the file. What is causing the error?
Edit: The problem goes away temporarily if I remove the .pyc file, but comes back next time.