Python Forum
Python 3.6.10 fails when running a localized script.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.6.10 fails when running a localized script.
#1
Hello,

Thanks for having me here. I am a new to python.

I am stuck with something which i think most of you might already know.
I have a py script that contains some Japanese (localized) strings. When i run this script in Python.exe version 3.6.10 it throws an error like:

'SyntaxError: Non-UTF-8 code starting with '\xe5' in file (..) but no encoding declared'

Can anyone let me know how to resolve it! Think

Thanks a ton.
Reply
#2
If the program is not encoded in UTF-8, you could add en encoding line as the first or the second line of the program, such as
# -*- coding: <encoding name> -*-
For a list of encoding names, you could list the content of the encodings directory in the python library. I don't know japanese at all but for example iso2022-jp-1 looks like a candidate for <encoding name>
Reply
#3
@Gribouillis : That magical line helped. Thanks a ton.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  No Internet connection when running a Python script basil_555 8 442 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 335 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Help Running Python Script in Mac OS emojistickers 0 306 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Trying to make a board with turtle, nothing happens when running script Quascia 3 607 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Anaconda 2.4.2: The JupyterLab 3.5.3 fails to run the python code of the Geographical jamalnuman 0 312 Aug-23-2023, 07:48 AM
Last Post: jamalnuman
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,004 Jun-29-2023, 11:57 AM
Last Post: gologica
  Python script running under windows over nssm.exe JaroslavZ 0 671 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  Running script with subprocess in another directory paul18fr 1 3,476 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  Running script on multiple files Afrodizzyjack 1 2,466 May-14-2021, 10:49 PM
Last Post: Yoriz
  Error when running script on startup in Linux NoahTheNerd 0 1,925 Mar-07-2021, 04:54 PM
Last Post: NoahTheNerd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020