samedi 6 décembre 2014

Python console in Mac: can't input accented characters


Vote count:

0




In OSX Yosemite, I open the terminal and start Python:



~ python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>


Now, impossible to type any accented character: éèàüö... All I get is a beep and nothing on screen. Copy pasting doesn't work either.


I tried re-installing Python and using different versions but no change.



asked 7 secs ago


1 Answer



Vote count:

0




It turns out that the answer was in the system locale settings. When doing:



~ locale
LANG=C
LC_COLLATE=
LC_CTYPE=
LC_MESSAGES=
LC_MONETARY=
LC_NUMERIC=
LC_TIME=
LC_ALL=


Something is wrong there. After doing:



export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8


Now I get:



~ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"


And in Python:



~ python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> é à à üü èè :)


answered 7 secs ago






Python console in Mac: can't input accented characters

Aucun commentaire:

Enregistrer un commentaire