My Python error...

S

SaMTHG

Basically I have Mac OS X 10.4.11 and I've got python 2.5.
When I go to TextEdit and type in something like
#!/usr/bin/env python
print 2+2
and save it as simplescript.py.
Then I go to terminal and cd my way to the dir that the script source
is in and type:
python simplescript.py
And the output is:
File "simplescript.py", line 1
SyntaxError: Non-ASCII character '\xfe' in file simplescript.py on
line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html
for details
What does this mean? And how do I make it work again?
Thanks for reading
SaMTHG
 
S

SaMTHG

It probably means that your text editor is saving as UTF-16 and it's
seeing part of a byte order marker (0xFE 0xFF or 0xFF 0xFE depending on
endianness) -- either that or you've accidentally injected some extra
garbage into the file. Save as ASCII instead.

--
Erik Max Francis && (e-mail address removed) &&http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
Heaven ne'er helps the man who will not act.
-- Sophocles

Thank you I've got it to work now...I was saving the file as UTF-16
instead of UTF-8.
Now it works
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top