Re: Exception during numpy import

"Stefan Richthofer" <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <trinity-a5cf7567-49be-4d6b-a6fa-0b4df8301573-1422547222866@3capp-gmx-bs31>
Hello Pradeep,

unfortunately Numpy is not supported by Jython, as it is a native C-extenstion for CPython, which are not compatible with Jython in general.

However using JyNI (www.jyni.org) one can at least use basic C-extensions with Jython, currently linux-only. I hope to get it working with Numpy

within half a year or so (but actually estimated this time frame one year ago^^).

Until then your best bet would be Numpy4J (https://github.com/JosephCottam/Numpy4J) which accesses NumPy from java by embedding the CPython

interpreter. It does not integrate with Jython, but you can write a java class wrappering the numpy-functions you need and then acces this class from

Jython.

These Non-Numpy-specific general aproaches to embed CPython in Java are also worth a look:

JPY:

http://jpy.readthedocs.org/en/latest/intro.html

Jepp/Jep:

http://jepp.sourceforge.net

https://github.com/mrj0/jep

- Stefan

Gesendet: Donnerstag, 29. Januar 2015 um 16:35 Uhr

Von: "Pradeep Badiger" <[email protected]>

An: "[email protected]" <[email protected]>

Betreff: [Jython-dev] Exception during numpy import

Hi,

I am trying to import numpy (1.9.1 for python 2.7) package in a jython script and this script is executed using jython-standalone (v 2.7-b1) APIs.

I have set the path to numpy by setting the properties in PythonInterpreter

Properties props = new Properties();

props.setProperty("python.path", "C:\\Python27\\Lib\\site-packages");

PythonInterpreter.initialize(System.getProperties(), props, new String[] {""});

I am getting following exception while evaluating the script.

javax.script.ScriptException: SyntaxError: 'import *' not allowed with 'from .' in C:\Python27\Lib\site-packages\numpy\__init__.py at line number 182 at column number 4

at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:190)

at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)

at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)

at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)

at com.fico.dmip.scriptjs.PythonScriptExecutor.<init>(PythonScriptExample.java:68)

at com.fico.dmip.scriptjs.PythonScriptExample.main(PythonScriptExample.java:50)

Also I tried with jython-standalone-2.7.b3 and it gave me a different exception.

console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.

javax.script.ScriptException: ImportError: No module named type_check in <script> at line number 3

at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:202)

at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:42)

at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)

at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)

at com.fico.dmip.scriptjs.PythonScriptExecutor.<init>(PythonScriptExample.java:68)

at com.fico.dmip.scriptjs.PythonScriptExample.main(PythonScriptExample.java:50)

Can someone help me on which version of numpy is supported with the release of jython?

Thanks,

Pradeep V.B.

This email and any files transmitted with it are confidential, proprietary and intended solely for the individual or entity to whom they are addressed. If you have received this email in error please delete it immediately. ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/_______________________________________________ Jython-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jython-dev

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/

_______________________________________________
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.