1

I'm trying to setup a project in PyCharm, but I get an error when I try to execute it.

SyntaxError: Non-ASCII character '\xca' in file /Users/raddevon/PycharmProjects/pygame/env-pygame/bin/python on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

I've setup a virtual environment for my project and have installed PyGame in the virtual environment. This generated a different error until I installed the PyGame binaries for Mac on my system. Now, I'm stuck at another point.

When I opened the project in PyCharm, I expected it would detect the virtual environment and configure the interpreter automatically, but I had to do this manually. I have done so and that seemed to work, but I am unable to execute due to this error.

EDIT: I had configured the IDE to try running Python with the Python interpreter rather than the script I actually wanted to run. I've got a new error now, but at least I'm making progress. Thanks to @nightcracker for setting me on the right path.

2
  • What are the contents of /Users/raddevon/PycharmProjects/pygame/env-pygame/bin/python? What do you execute? Commented Mar 8, 2012 at 14:13
  • @nightcracker You sent me in the right direction. This being the first time I had manually configured the interpreter, I mis-interpreted (heh) the configuration and had the interpreter trying to run itself. I have corrected that, and I'm now running into a different error. Off to research that for a bit. Thanks! Commented Mar 8, 2012 at 14:30

1 Answer 1

4

Perhaps try adding the following:

# -*- coding: utf-8 -*-

at the top of your sourcefiles?

As the error message suggests you may want to visit PEP 0263 and then declare the encoding as I proposed above.

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

4 Comments

I vaguely understood the encoding thing, but the error seems to say the encoding problem is within Python itself which is why I hadn't tried anything on my source files. I only have a single file at the moment. I tried adding that to my file, but I get the same error.
So perhaps as @nightcracker suggests, you could give us more detail. Can you show us how do you execute and the contents of the problematic file?
I found the problem. See my original post. It was stupidity on my part. Thank you so much!
I'm glad you figured this out. Good luck ! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.