How to enter Japanese when using Python 3 IDLE on a Mac

Asked 2 years ago, Updated 2 years ago, 33 views

I would like to use Japanese after # in Python 3. Please tell me how to do it in an easy-to-understand way.Screenshot

python python3

2022-09-30 18:35

3 Answers

IDLE Shell

WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

Does it say ??

Exactly as it says, the version of Tcl/Tk with macOS, 8.5.9, is unstable and has a serious bug ("the Apple-supplied Tcl/Tk 8.5 still has serial bugs" via http://www.python.org/download/mac/tcltk/.

There have also been reports that Japanese cannot be entered, and some people have reported that it was resolved after 8.5.11.
I myself have confirmed that I can enter Japanese with the latest ActiveTcl at this time.

Download/install ActiveTcl from the link and use a different Python instead of the one that comes with macOS.
If you're already using Python that doesn't come with macOS, try recompiling or reinstalling it to see the newly installed Tcl/Tk.


2022-09-30 18:35

As of April 2018, I am using Sierra and High Sierra, but I understand that I cannot input Japanese on Python's Tkinter with macOS.

I also know that I can't see the text in the middle of conversion on ActiveTcl's Tk.
(It will be displayed once the input is confirmed, so it is not impossible to input.)

If you copy/paste the Japanese text you entered in another editor, unfortunately it is not easy to use.

This happens not only in python, but also in Ruby and R who use the same Tk.
(Because it's a Tcl/Tk issue)


2022-09-30 18:35


Encoding scripts (character codes) On the first or second line

#coding:encoding name
# coding = encoding name

Write in the form of either of the .
(In exactly the format Linked )

For example, for UTF-8,

#coding:UTF-8

Write as shown in .
This will help you understand that the script is written in UTF-8.

#-*-coding:utf-8-*-

You may see the code that says
This way, the editor Emacs will understand the encoding of the script.
See Linked for possible encodings.

Browse: Defining the Encoding


2022-09-30 18:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.