Click here to Skip to main content
14,843,569 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
after i save a python file and shut down my pc when i restart it and right click the file and select edit with idle which i used to write the file it gives me this error message:

the files encoding is invalid for python 3x
idle will convert to utf-8
what is the correct encoding for the file?

how do i find out what the encoding is or is there a way i can set the encoding in the file with a line of code up top by my imports ? please help

What I have tried:

not sure what to try very new to python
cant find any info on this matter
Updated 25-Aug-20 19:34pm

My first suspect is the Python version. Probably your file is in v2.x and now you are trying to open in v3.x

Further, in order to move ahead, maybe just opening the file in Notepadd++ or any similar editor and then save with utf-8 encoding should do the job here. (without knowing what was the encoding)

Try the options and see.
I have IDLE version 3.7.1.and it is saving the file in standard ANSI format. Can you examine the file with a hex editor and tell us the value of the first few bytes?
i did some trial and error and all the files work with 3.6.6 but they give me that encode error with newer versions i dont know what the issue is yet if its code or something still working on that part
Richard MacCutchan 26-Aug-20 3:27am
See my question above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900