Re: Exception during numpy import

Pradeep Badiger <[email protected]>
Newsgroups gmane.comp.lang.jython.devel
Message-ID <DDFE6B42B194104F903A334F685DC899095350@mbx025-wd-ca-2.exch025.domain.local>
Thanks Stefan. I will go through JyNI and the links to others that you provided.

Thanks,
Pradeep V.B.

From: Stefan Richthofer [mailto:[email protected]]
Sent: Thursday, January 29, 2015 11:00 AM
To: Pradeep Badiger
Cc: [email protected]
Subject: Aw: [Jython-dev] Exception during numpy import

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<http://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]<mailto:[email protected]>>
An: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[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]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/jython-dev

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