Eclipse 插件 + Jython - 未处理的事件循环异常
Eclipse Plugin + Jython - Unhandled event loop exception
以防万一其他人试图在自建的 eclipse 插件中使用 Jython。我因以下错误而苦恼了 2 天,这是在我尝试通过 interpreter.exec("from myScript import *\n");
:
导入我的 python 脚本时发生的
!ENTRY org.eclipse.ui 4 0 2015-12-11 11:22:53.549
!MESSAGE Unhandled event loop exception
!STACK 0
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/eclipse/luna/../../../common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/src/scripts/iecommon.py", line 6, in <module>
from xml.dom import minidom
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/dom/__init__.py", line 226, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/dom/MessageSource.py", line 19, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/FtCore.py", line 38, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/FtCore.py", line 38, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/gettext.py", line 58, in <module>
File "/opt/eclipse/luna/../../../common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/posixpath.py", line 77, in join
AttributeError: 'NoneType' object has no attribute 'endswith'
需要将 属性 python.home
设置为某个值。看起来哪个值都没有关系.. 将它留空是不行的。
设置 属性 例如可以在 java-code:
中完成
String jythonJarPath = "target/lib/jython-standalone-2.7.0.jar";
String pythonLibPath = SilecsUtils.findInBundle(jythonJarPath);
Properties sysProps = System.getProperties();
sysProps.setProperty("python.path", pythonLibPath + "/Lib");
sysProps.setProperty("python.home", ".");
以防万一其他人试图在自建的 eclipse 插件中使用 Jython。我因以下错误而苦恼了 2 天,这是在我尝试通过 interpreter.exec("from myScript import *\n");
:
!ENTRY org.eclipse.ui 4 0 2015-12-11 11:22:53.549
!MESSAGE Unhandled event loop exception
!STACK 0
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/eclipse/luna/../../../common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/src/scripts/iecommon.py", line 6, in <module>
from xml.dom import minidom
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/dom/__init__.py", line 226, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/dom/MessageSource.py", line 19, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/FtCore.py", line 38, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/xml/FtCore.py", line 38, in <module>
File "/common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/gettext.py", line 58, in <module>
File "/opt/eclipse/luna/../../../common/home/bel/schwinn/lnx/workspace-silecs/silecs-configuration/target/lib/jython-standalone-2.7.0.jar/Lib/posixpath.py", line 77, in join
AttributeError: 'NoneType' object has no attribute 'endswith'
需要将 属性 python.home
设置为某个值。看起来哪个值都没有关系.. 将它留空是不行的。
设置 属性 例如可以在 java-code:
String jythonJarPath = "target/lib/jython-standalone-2.7.0.jar";
String pythonLibPath = SilecsUtils.findInBundle(jythonJarPath);
Properties sysProps = System.getProperties();
sysProps.setProperty("python.path", pythonLibPath + "/Lib");
sysProps.setProperty("python.home", ".");