I'm trying to execute a python function, written inside a .py file from my java project (spring boot) deployed to AWS EC2.
At start I located the .py file in the resource folder, but it didn't work properly so I uploaded the .py file to S3 and I download it from there every time I need to.
I use the following to run the python file:
Process processBuilder = Runtime.getRuntime().exec("python word2vec.py");
Locally it works great, but since word2vec.py has dependencies, such as gensim, when executed in the EC2 instance (linux based) I get the error "ImportError: No module named gensim", which makes sense since I didn't install it on the machine.
Using IntelliJ plugin for python I created a virtual environment in the project and installed gensim so it works locally, is there a way to do it in the EC2 instance?
Since the project is packed into a jar file, even if the .py is located in the resource folder, the "Runtime.getRuntime().exec(...)" function can't access it, I get "file not found".
Is there a way to keep everything inside the java project/jar? or I need to install python virtual environment manually on the EC2 instance?