如何使用 Jython/PyDev 修复 Eclipse Kepler/Luna 中的 UnsupportedCharsetException?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30443537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:39:58  来源:igfitidea点击:

How do I fix UnsupportedCharsetException in Eclipse Kepler/Luna with Jython/PyDev?

javapythoneclipsepydevjython

提问by Ericson Willians

Example code:

示例代码:

from java.lang import System

if __name__ == '__main__':
    [System.out.print(x) for x in "Python-powered Java Hello World from within a List-Comprehension."]

Annoying output:

烦人的输出:

console: Failed to install 'org.python.util.JLineConsole': java.nio.charset.UnsupportedCharsetException: cp0.
console: Failed to install 'org.python.util.JLineConsole': java.nio.charset.UnsupportedCharsetException: cp0.
Python-powered Java Hello World from within a List-Comprehension.

I've tried the solution described hereand here. Both solutions failed miserably (I've added the -Dpython.console.encoding=UTF-8 argument to the JVM and the PyDev interactive console).

我已经尝试了此处此处描述的解决方案。两种解决方案都失败了(我已将 -Dpython.console.encoding=UTF-8 参数添加到 JVM 和 PyDev 交互式控制台)。

There's also another question about it here from 4 months ago, and no one answered it. So, how do I fix it?

4个月前这里还有一个关于它的问题,没有人回答。那么,我该如何解决呢?

EDIT: I've just installed the new Eclipse Luna, installed PyDev with Jython, and the same thing happens.

编辑:我刚刚安装了新的 Eclipse Luna,用 Jython 安装了 PyDev,同样的事情发生了。

采纳答案by Ericson Willians

I've fixed the problem by downgrading Jython from 2.7.0 to 2.5.4rc1. It seems to be an issue of Python 3.4 with Jython 2.7.0.

我通过将 Jython 从 2.7.0 降级到 2.5.4rc1 解决了这个问题。这似乎是 Python 3.4 与 Jython 2.7.0 的问题。

So, I've downloaded the Jython 2.5.4rc1 - Standalone Jar, and changed the Jython interpreter manually on Eclipse Luna by going: Window -> Preferences -> PyDev -> Interpreters -> Jython Interpreter -> Removing the current Jython Interpreter -> New Button (Adding the downloaded standalone .jar).

所以,我已经下载了Jython 2.5.4rc1 - Standalone Jar,并通过以下方式在 Eclipse Luna 上手动更改了 Jython 解释器:窗口 -> 首选项 -> PyDev -> 解释器 -> Jython 解释器 -> 删除当前的 Jython 解释器 ->新按钮(添加下载的独立 .jar)。

Now we have to wait to see if the Jython bug will go away on the next version of Jython (Perhaps it's not an issue of Python 3.4, but an issue with Eclipse itself. In all cases, I've test both with Kepler and Luna, and the error persisted. I did not test with Python 2.7, so I don't know).

现在我们必须等待 Jython 错误是否会在下一版本的 Jython 上消失(也许这不是 Python 3.4 的问题,而是 Eclipse 本身的问题。在所有情况下,我都用 Kepler 和 Luna 进行了测试,并且错误仍然存​​在。我没有使用 Python 2.7 进行测试,所以我不知道)。

Case closed.

案件结案。

回答by user826366

I've fixed this issue following the advice mentioned in the bug report you referred to (http://bugs.jython.org/issue2222), adding -Dpython.console.encoding=UTF-8 as a VM argument to the run configuration for my program. Setting the same value as an environment variable for the Jython interpreter didn't work in my case.

我已经按照您提到的错误报告(http://bugs.jython.org/issue2222)中提到的建议修复了这个问题,将 -Dpython.console.encoding=UTF-8 添加为运行配置的 VM 参数对于我的程序。为 Jython 解释器设置与环境变量相同的值在我的情况下不起作用。

I'm using Jython 2.7.0 and Eclipse Luna with PyDev on Windows 7.

我在 Windows 7 上使用 Jython 2.7.0 和 Eclipse Luna 和 PyDev。

回答by Fabio Zadrozny

Well, I think this isn't really related to PyDev (only Jython)... (you can double check by running it in the command line).

好吧,我认为这与 PyDev(仅 Jython)并没有真正的关系……(您可以通过在命令行中运行它来仔细检查)。

I think what you're seeing is the same thing as the following report at the Jython tracker: http://bugs.jython.org/msg8448

我认为您所看到的与 Jython 跟踪器上的以下报告相同:http: //bugs.jython.org/msg8448

回答by pandeg

I have installed Python 3.5.2 in Neon eclipse and found the same issue.

我已经在 Neon eclipse 中安装了 Python 3.5.2 并发现了同样的问题。

Added -Dpython.console.encoding=UTF-8 as a VM argument as mentioned by user826366. I am not seeing any issue now.

添加 -Dpython.console.encoding=UTF-8 作为 user826366 提到的 VM 参数。我现在没有看到任何问题。

回答by sborai

add "-Dpython.console.encoding=UTF-8" to the Run Configurations -> VM arguments.

将“-Dpython.console.encoding=UTF-8”添加到“运行配置”->“VM 参数”。

回答by Olu Smith

I had a similar issue and all i did was to specify the encoding to in my case UTF-8 in eclipse as a VM Argument, apply and run.

我有一个类似的问题,我所做的就是在我的情况下将编码指定为 Eclipse 中的 UTF-8 作为 VM 参数,应用并运行。

 -Dpython.console.encoding=UTF-8

回答by Narayan Kumar

I was facing same issue and added below argument to resolve -Dpython.console.encoding=UTF-8

我遇到了同样的问题并添加了以下参数来解决 -Dpython.console.encoding=UTF-8