How to import pandas using jython

I am new to python and I am installing Jython2.7.0

Java

import org.python.util.PythonInterpreter;
import org.python.core.*; 

public class Main {
    public static void main(String[] args) {
         PythonInterpreter interp = new PythonInterpreter(); 
         interp.execfile("D:/Users/JY/Desktop/test/for_java_test.py");  
         interp.close();
    }
}

Python

import pandas as pd
import ctypes

def main():
    data = pd.read_csv('for_test.csv')
    data_mean = data.a*2
    data_mean.to_csv('catch_test.csv',index=False)
    ctypes.windll.user32.MessageBoxW(0, "Done. Output: a * 2", "Output csv", 0)

if __name__ == '__main__':
    main()

Then I got this error.

Exception in thread "main" Traceback (most recent call last):
File "D:\Users\JYJU\Desktop\test_java\for_java_test.py", line 1, in <module>
    import pandas as pd
ImportError: No module named pandas

How can I fix this if I want to use pandas?

+4
source share
2 answers

You cannot currently use Pandas with Jython, as it depends on the specific internal extensions of CPython. One dependency is NumPy, the other is Cython (which is not actually a native extension of CPython, but generates such).

JyNI project ( " Jython Native Interface" ). Jython CPython-, - , . , Pandas NumPy Jython, .

(, ctypes .)

, POSIX ( Linux OSX).

Jython, Java/Pandas, CPython. JPY JEP - , , Java Pandas ( , CPython).

+4

, pandas cython CPython. , CPython Python ( , ).

Jython - Python Python JVM Java Python Java ..

Python, CPython (, pandas), Python ( , CPython, Jython, PyPy IronPython)

Jython pandas , , .

Java - Jython, JVM ( Java-, Jython, Python, , , Java), CPython , pandas.

IPC ( ) ( IO, , OS-, , memcache, Redis ..).

Java CPython ( ), , CPython pandas ( ).

(- ) / ( , ).

, , Java CSV CPython, CPython CSV pandas, CSV Java-.

+3

All Articles