I am running a python program called diagnostics.py from a java class called PyInterpreter that intializes a jython PythonInterpreter object and a file to use and can run methods from that python program. My python program looks like this:
import datetime
import psutil
class HeartbeatGenerator:
...
and when I try to run this program, I get the error:
Exception in thread "main" Traceback (most recent call last):
File "../../../eclipse-workspace/Diagnostics/diagnostics.py", line 2, in <module>
import datetime
ImportError: No module named datetime
I have installed datetime and psutil with pip and they are in /usr/local/bin/python3.7/site-packages as well as /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages. I have also copied and pasted the necessary files from that location into my jython.2.5.3/lib/site-packages, and in my PyInterpreter file, I have tried setting my system properties for python.home and python.path as seen:
public PyInterpreter()
{
Properties props = System.getProperties();
props.setProperty("python.home", "/usr/local/lib/python3.7");
props.setProperty("python.path", "/usr/local/lib/python3.7/site-packages");
System.out.print(props);
PythonInterpreter.initialize(System.getProperties(),
props,
new String[0]);
this.interpreter = new PythonInterpreter();
}
but no matter what I set the sys properties to, I still get the same error. Right now it is only on the line to import datetime, but I know if I had import psutil
first, it would break on that line too. Any ideas?