获取环境失败,+java.lang.ExceptionInInitializerError,追踪IO错误:文件未找到

2024-05-19 06:47:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我在64位系统上运行Windows7。 我使用netbeans6.9.1(安装了python插件) 同时安装:Python2.7.1(64),JDK6更新24(64)

我对术语提取感兴趣,所以我下载了montylingua,它应该运行在Java或/和Python中。 这是链接:http://web.media.mit.edu/~hugo/montylingua/

当我试图运行示例.java压缩文件中包含的代码,我遇到了以下问题:

****** MontyLingua v.2.1 ******
***** by hugo@media.mit.edu *****
Failed to get environment, environ will be empty: (0, 'Failed to execute command ([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run program "sh": CreateProcess error=2, The system cannot find the file specified')

java.lang.ExceptionInInitializerError
Caused by: Traceback (innermost last):
  File "C:\work\montylingua-2.0\copy\JMontyLingua.py", line 0, in __init__ 
  File "C:\work\montylingua-2.0\copy\MontyLingua.py", line 0, in __init__ 
  File "C:\work\montylingua-2.0\copy\MontyLemmatiser.py", line 0, in __init__ 

IOError: File not found - 
    at org.python.core.Py.IOError(Py.java)
    at org.python.core.PyFile._setup(PyFile.java)
    at org.python.core.PyFile.<init>(PyFile.java)
    at org.python.core.__builtin__.open(__builtin__.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at montylingua.MontyLemmatiser$_PyInner.__init__$5(MontyLemmatiser.java:5312)
    at montylingua.MontyLemmatiser$_PyInner.call_function(MontyLemmatiser.java:5219)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyFunction.__call__(PyFunction.java)
    at org.python.core.PyInstance.__init__(PyInstance.java)
    at org.python.core.PyClass.__call__(PyClass.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at montylingua.MontyLingua$_PyInner.__init__$1(MontyLingua.java:218)
    at montylingua.MontyLingua$_PyInner.call_function(MontyLingua.java:163)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyFunction.__call__(PyFunction.java)
    at org.python.core.PyInstance.__init__(PyInstance.java)
    at org.python.core.PyClass.__call__(PyClass.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at montylingua.JMontyLingua$_PyInner.__init__$1(JMontyLingua.java:85)
    at montylingua.JMontyLingua$_PyInner.call_function(JMontyLingua.java:63)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyFunction.__call__(PyFunction.java)
    at org.python.core.PyInstance.__init__(PyInstance.java)
    at org.python.core.Py.initProxy(Py.java)
    at montylingua.JMontyLingua.__initProxy__(JMontyLingua.java:256)
    at montylingua.JMontyLingua.<init>(JMontyLingua.java:234)
    at montylinguaapplication.MontySample.<clinit>(MontySample.java:8)
Could not find the main class: montylinguaapplication.MontySample.  Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)

我对Java很熟悉,因为我有一些小的编程经验。我对Python一无所知。 montylingui是运行环境变量所必需的。在

我看过一篇关于Jython的帖子,他的第一个错误和我一样,但我没能从提议中做任何事情。(另一篇文章的链接:Jython - javaos.getenv() gives "Failed to get environment, environ will be empty"

任何能正确运行这个.java文件的人都可以推荐一些东西。在

我也可以上传java代码,但我认为它是过时的,因为它是可用的,而且很容易在提到的网站找到。。。在

在这个项目中,我还包括了JyDT_Update_Site_1.4.15 zip,以防这会有所帮助,但不幸的是什么都没有发生。在

也许我必须在一个特定的文件中添加一些代码,就像在另一篇文章中那样,但是我不知道在我的系统中应该在哪个文件中添加什么。在

谢谢你的时间。在


Tags: orgcoreinitjavacallatpyobjectpyfunction
3条回答

解决方案是在Jython注册表文件中设置属性python.os。在

您可以按照以下说明找到注册表文件:http://www.jython.org/archive/21/docs/registry.html#finding。在

在我看来和你链接的帖子里的问题是一样的。在

'Failed to execute command ([\'sh\', \'-c\', \'env\']): java.io.IOException: Cannot run program "sh":

意味着jython被配置为认为它运行在某种UNIX系统上。在

看起来python代码正在尝试运行shell命令。 但是,既然你在Windows上,这不起作用。在

这让我想知道这是否真的是在python中获取环境的规范方法?在

相关问题 更多 >

    热门问题