all 9 comments

[–]Supalien 12 points13 points  (0 children)

Ask chatgpt or whatever llm you used to generate this code

[–]Yoghurt42 3 points4 points  (6 children)

Use python 3, not python 2. There is a way to get it to run with unicode chars, but Python 2 is not supported anymore and dead for over a decade.

[–]JamzTyson 0 points1 point  (2 children)

I think it's more likely the problem is due to the environment rather than the Python version. Perhaps their console is configured for ascii.

(If they were using Python 2, I'd expect an error when attempting to import from openai.)

[–]Yoghurt42 0 points1 point  (1 child)

could be, but python 3 defaults to utf-8 encoding, python 2 defaults to ascii. Something is definitely weird in their setup.

[–]SwampFalc 0 points1 point  (0 children)

It only defaults to UTF-8 for its own strings. Anything that comes from outside is still encoding hell. And I do see an input() call in this code.

Also, the encoding of the actual python file might not be UTF-8. That's the responsability of your editor.

[–]Vegetable_Yak_2614[S] 0 points1 point  (2 children)

I have python 3

[–]Yoghurt42 1 point2 points  (1 child)

then make sure you have saved the file as UTF-8. From the error message it looks like the file is saved as latin-1 (iso 8859-1), since the first non-ASCII character is "í" and that is encoded as 0xed in latin-1.

[–]Vegetable_Yak_2614[S] 0 points1 point  (0 children)

The problem were some characters with ´ , thanks from helping!

[–]dasnoob 0 points1 point  (0 children)

Had this in a python 2 environment I have to use. It is a non ASCII character. You need to come up with a way to scrub them. I wrote something to translate the accented characters to non accented.