Hey Joey, thanks for sharing your issue. I also had this problem previously, but mine was down to not typing in line 15 correctly. Your code looks the same as mine, but when I copied yours into my own text editor and then ran it, it didn’t appear to do anything.
Only thing I can see is that on line 18 print(raw_bytes. “<===>”, cooked_string) your print command isn’t shown in bold by the editor, whereas in my code, it is, and everything else bold in yours shows the same way in mine. Maybe it isn’t identifying print on line 18 as a command like import, def, if and return? They’re all highlighted bold in the editor, but it isn’t.
Yes I’m using python 3.7, I also think it is a windows problem I’m running 8.1, should I try to fix it if it’s a windows problem and how to do so if I should fix it?
First, make sure that you really use Python3.7. I had some confusions earlier on with two installed version. Maybe you installed one months or years ago and don’t remember it.
Run your script like that:
python3.7 test.py utf-8 strict
If you still have the problem, I can’t help you. You have to copy the error message and paste it into google and search around. Good luck.
Hey @Joey, don’t feel bad at all. Programming sucks and is the most frustrating thing ever and then YOU FIX IT OH WOW YOU ARE A GOD and then it sucks again and it’s the most frustrating thing ever AND THEN YOU FIX IT YOU CAN DO ANYTHING IN THE WORLD and then…
In this case, you are most likely using a Windows computer that has a non-English default language. You clicked on the link for the languages.txt file, and Windows tried to “help” by converting my beautiful utf-8 encoded file into your non-English language encoding. Now when you tell it utf-8 in the program it barfs and you get this error.
Two ways to fix it:
Specify your computer’s language encoding instead of utf-8 when you run it. This is the hardest.
Delete languages.txt and then go back and instead of clicking on the file, right click and Save As… which seems to not mangle the file.
I don’t think there is anything wrong with the .py file. I would open languages.txt in notepad and check the encoding. Also, from powershell are you typing in python ex23.py utf-8 strict to match the command line arguments in the script?
For the future, if you get an error in a line that looks good, scrutinise the lines before. Especially syntax errors are often caused by little slips like this one.
I am having a similar issue, but it shows no output at all nor any errors? Kindly assist or provide a solution, I am using windows 10 with PycharmCE/Thonny/IDLE/Powershell, at all executions it do not give out any error or output. Here is my code: