Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JEP : jep.JepException : Error importing numpy #525

Open
roopannava opened this issue Mar 30, 2024 · 3 comments
Open

JEP : jep.JepException : Error importing numpy #525

roopannava opened this issue Mar 30, 2024 · 3 comments

Comments

@roopannava
Copy link

Problem
jep.JepException: <class 'ImportError'>: Error importing numpy: you should not try to import numpy from
2024-03-29 14:13:17,426 ERROR [stderr] (Timer-6) its source directory; please exit the numpy source tree, and relaunch
.

Environment :

  • Centos 7.9
  • Python 3.12
  • Java Distribution and Version: jdk 11
  • Jep Version: jep-4.2.0
  • Python packages used : numpy, pandas, patsy , joblib

I am setting up JEP/Java and accessing a python functions which has numpy, pandas,patsy and joblib.
My project is working fine in my local Mac environment. When I push the code to Centos 7.9, I am getting "Import Error".
I have read the articles https://stackoverflow.com/questions/14570011/explain-why-numpy-should-not-be-imported-from-source-directory but I couldn't resolve the issue when I move the python packages to another path.

Troubleshooting:
sys.path : I am logging out this when my java method call the python function:
Value: ['/usr/local/lib/python312.zip', '/usr/local/lib/python3.12', '/usr/local/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/site-packages', '/mypython/modlel'

JEP:

(jep is installed under the site-packages)

Observations:
I can see the interpreters is initialized but when function call goes, I am getting the "Import Error"

What I am doing wrong here?
I have installed all the packages with pip3.12
It is working fine in Mac

Please help!
thank you

@roopannava
Copy link
Author

    jepPath = /my/site-packages/jep/libjep.so
    MainInterpreter.setJepLibraryPath(jepPath);
    jep.JepConfig jepConf = new JepConfig();
    jepConf.addIncludePaths("/my/pythonmodel");
    jepConf.addIncludePaths("/my/site-packages");
    SharedInterpreter.setConfig(jepConf);

@roopannava
Copy link
Author

I figured out the root cause. I have to place the python module file under the …./site-packages.

@Dynasty-develop
Copy link

I meet same trouble. But I don`t understand your solution. Can you please interpreter more detail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants