I'd like to use python modules in my python code. But I think jepp cannot handle it properly.
For example:
>>>from sklearn import linear_model
>>>clf = linear_model.LinearRegression()
>>>clf.fit ([[0, 0], [1, 1], [2, 2]], [0, 1, 2])
>>>LinearRegression(copy_X=True, fit_intercept=True, normalize=False)
>>>clf.coef_
>>>array([ 0.5, 0.5])
Jepp seems to run forever after the first line: no error message or exception(I call these lines from eclipse with jep.eval("script") ), but the code works if I run it from the python interpreter 'manually'.
It doesn't work either if I use it in this way:
>>>import sklearn
>>>clf = sklearn.linear_model.LinearRegression()
>>>...same as above...
In this case I get the following error message: "SEVERE: null
jep.JepException: jep.JepException: : 'module' object has
no attribute 'linear_model'
at jep.Jep.eval(Jep.java:294)
at Main.executeScript(Main.java:72)
at Main.main(Main.java:36)
Caused by: jep.JepException: : 'module' object has no
attribute 'linear_model'
at jep.Jep.eval(Native Method)
at jep.Jep.eval(Jep.java:278)
... 2 more"
My only working version with modules is:
import numpy as np
beta = np.array([1, 0.1, 10])
So I need a solution in order to
- use code: 'module.submodule.function'
- use import: 'import module.submodule' and use code: 'submodule.function'
Is it possible?
I'm using python 2.7.2 and jep 2.4 on Ubuntu 12.04. And I call the code above from eclipse, where I set these environment variables:
- LD_PRELOAD /usr/lib/libpython2.7.so
- LD_LIBRARY_PATH /usr/local/lib/python2.7/dist-packages/
I know there's a newer version of jepp but for me it was hard to configure 2.4. too, so I wouldn't install a newer if it's unnecessary. (Because it was time-consuming for me. I had to compile a totally new python interpreter with ucs4, copy the installed python packages from dist-packages to site-packages, set environment variables and so on.)
Thanks in advance!
There's another sourceforge project called pyro4. It can handle python modules like: numpy, sklearn... And maybe it's even better because it is currently developed. (last jepp version was released in 2010)