开发者

Failed to get environment, + java.lang.ExceptionInInitializerError, Traceback IOError: File not found -

开发者 https://www.devze.com 2023-03-05 01:27 出处:网络
I run windows 7 on a 64bit system. I use netbeans 6.9.1 (the python plug ins are installed) Installed also: Python 2.7.1(64), JDK 6 update 24(64),

I run windows 7 on a 64bit system. I use netbeans 6.9.1 (the python plug ins are installed) Installed also: Python 2.7.1(64), JDK 6 update 24(64),

I'm interested in term extraction so I downloaded montylingua which is supposed to run in Java or/and Python. this is the link: http://web.media.mit.edu/~hugo/montylingua/

When I try to run the Sample.java code included in the zip file available, I encounter these problems:

****** 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.co开发者_如何学运维re.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)

I am familiar with Java since I have some small programming experience with it. I know nothing about Python. I have set the environment variable "MONTYLINGUA" which is necessary for the program to run.

I have seen a post about Jython from somebody who gets the same first error as me, but I was not able to do anything from the things proposed. (the link of the other post: Jython - javaos.getenv() gives "Failed to get environment, environ will be empty")

Anyone who can run this .java file correctly may recommend something.

I can upload the java code also, but I think it is obsolete since it is available and easy to find in the site mentioned...

In the project I included also the JyDT_Update_Site_1.4.15 zip, just in case that this would help, but unfortunately nothing happened.

Maybe I have to add some code in a specific file, like in the case of the other post, but I don't know in which to add what, in my system.

thank you for you time.


Looks to me like the same issue as the one from the post you linked.

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

Implies that jython is configured to think it's running on a UNIX system of some sort.


The solution is to set in the Jython registry file the property python.os.

You can locate the registry file following these instructions: http://www.jython.org/archive/21/docs/registry.html#finding.


It looks like the python code is trying to run a shell command. But, since you're on Windows, this does not work.

It makes me wonder if this is really the canonical way to get at the environment in python?


You will need the Sun Java compiler, version 1.4.2, installed on your system. Without it, you will have trouble runningthe MontyLingua Java examples, and we are not sure whether you you can compile MontyLingua into a .NET DLL. Search www.sun.comfor version 1.4.2 of the Java SE Development Kit and install it.

0

精彩评论

暂无评论...
验证码 换一张
取 消