Can't make Eclipse (Luna) PyDev console use UTF-8

前端 未结 2 1116
梦毁少年i
梦毁少年i 2021-01-16 06:40

In Eclipse Luna (4.0.4) / Python 3.4.1 I can\'t get the PyDev 3.6.0 console to work with Unicode despite having tried several recommended corrective steps.

I attemp

相关标签:
2条回答
  • 2021-01-16 07:07

    For regular runs:

    The problem there is that the PYTHONIOENCODING is overridden by PyDev based on the encoding you used in the run configuration (which is the encoding used by the console view too -- so, it'd make no sense having a PYTHONIOENCODING with a value and the allocated console in the PyDev side with another value).

    You can change the encoding you're using for a run configuration in: Run > Run configurations > common > encoding.

    By default it'll use the encoding of the file being launched (you can change the default encoding for the workspace in general > workspace > text file encoding).


    For interactive console runs:

    For interactive console runs there's currently no API to change the encoding in the java side, so, one has to start Eclipse itself in a VM that uses UTF-8 by default... In practice, this means that you have to add:

    -Dfile.encoding=UTF-8

    to the vmargs of Eclipse in eclipse.ini (and in this case it's also recommended to set the PYTHONIOENCODING environment variable in the related interpreter and set it to UTF-8).

    0 讨论(0)
  • 2021-01-16 07:25

    Found it! (At least for Python 3.4.1, Eclipse Luna 4.0.4, PyDev 3.6.0.)

    In Eclipse, in Preferences —> PyDev —> Interpreters —> Python Interpreter, in the Environment tab, I added the environment variable PYTHONIOENCODING and specified its value as utf-8.

    The PyDev Interactive Console now properly displays the aforementioned Chinese characters (and Thai characters, too).

    0 讨论(0)
提交回复
热议问题