Re: Import Error: No module named os

John Chiang <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <CAGkm4TdzZa=LpyRs9yuL0kCnTja=rBV3wewBJcct9YXC5MOzHw@mail.gmail.com>
Hi,

I am currently working on a web application which allows user to upload/run
python script in web application. I copied jython-standalone-2.7.0.jar to
WEB-INF/lib and build web application as war file. however, I get a
following error when running a python script:

org.python.core.PyException: null

at org.python.core.Py.ImportError(Py.java:328)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.imp.import_first(imp.java:877)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.imp.import_module_level(imp.java:972)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.imp.importName(imp.java:1062)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.PyObject.__call__(PyObject.java:431)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.__builtin__.__import__(__builtin__.java:1232)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.imp.importOne(imp.java:1081)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.pycode._pyx18.f$0(<script>:11) ~[na:na]

at org.python.pycode._pyx18.call_function(<script>) ~[na:na]

at org.python.core.PyTableCode.call(PyTableCode.java:167)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.PyCode.call(PyCode.java:18)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.Py.runCode(Py.java:1386)
~[jython-standalone-2.7.0.jar!/:na]

at org.python.core.Py.exec(Py.java:1430) ~[jython-standalone-2.7.0.jar!/:na]

at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
~[jython-standalone-2.7.0.jar!/:na]

at
com.xactly.xsql.expression.arithmetic.ProcedureScalarOp.allocate(ProcedureScalarOp.java:92)
~[xsql-0.9.99-SNAPSHOT.jar!/:na]


I found a workaround by running jython installer and setting python.home by
specifying -Dpython.home=<jython install directory> as a JVM parameter. I
think the purpose of using jython-standalone-2.7.0.jar is to be able to run
jython without running installer.

How do I specify jython-standalone-2.7.0.jar as python.home? I think
somehow it needs Lib directory which is inside of jar.


Any recommendations are appreciated. Thanks

John

On Tue, Sep 22, 2015 at 3:49 PM, John Chiang <[email protected]>
wrote:

> Hi,
>
> I am currently working on a web application which allows user to
> upload/run python script in web application. I copied
> jython-standalone-2.7.0.jar to WEB-INF/lib and build web application as war
> file. however, I get a following error when running a python script:
>
> org.python.core.PyException: null
>
> at org.python.core.Py.ImportError(Py.java:328)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.imp.import_first(imp.java:877)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.imp.import_module_level(imp.java:972)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.imp.importName(imp.java:1062)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.PyObject.__call__(PyObject.java:431)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.__builtin__.__import__(__builtin__.java:1232)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.imp.importOne(imp.java:1081)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.pycode._pyx18.f$0(<script>:11) ~[na:na]
>
> at org.python.pycode._pyx18.call_function(<script>) ~[na:na]
>
> at org.python.core.PyTableCode.call(PyTableCode.java:167)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.PyCode.call(PyCode.java:18)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.Py.runCode(Py.java:1386)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.core.Py.exec(Py.java:1430)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
> ~[jython-standalone-2.7.0.jar!/:na]
>
> at
> com.xactly.xsql.expression.arithmetic.ProcedureScalarOp.allocate(ProcedureScalarOp.java:92)
> ~[xsql-0.9.99-SNAPSHOT.jar!/:na]
>
>
> I found a workaround by running jython installer and setting python.home
> by specifying -Dpython.home=<jython install directory> as a JVM parameter.
> I think the purpose of using jython-standalone-2.7.0.jar is to be able to
> run jython without running installer.
>
> How do I specify jython-standalone-2.7.0.jar as python.home? I think
> somehow it needs Lib directory which is inside of jar.
>
>
> Any recommendations are appreciated. Thanks
>

-- 


[image: What's New with Xactly] <http://www.xactlycorp.com/email-click/>

<https://www.nyse.com/quote/XNYS:XTLY>  [image: LinkedIn] 
<https://www.linkedin.com/company/xactly-corporation>  [image: Twitter] 
<https://twitter.com/Xactly>  [image: Facebook] 
<https://www.facebook.com/XactlyCorp>  [image: YouTube] 
<http://www.youtube.com/xactlycorporation>

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.