Python Importerror When Calling Python Script From Java
First off, there is a similar question here that wasn't ever really resolved. I have a Python script that I want to execute from within my Java code. When I run the Python script o
Solution 1:
I solved it. It looks like ProcessBuilder
requires the full path not only to the python file itself, but to python:
ProcessBuilder("/Library/Frameworks/Python.framework/Versions/2.7/bin/python",absolute_file_path);
This solves the issue.
Solution 2:
$ cat ~/.bash_profile
Java code
ProcessBuilderpb=newProcessBuilder("/Users/micklin/anaconda2/bin/python","sentiment.py",done.toString());
code above is put in TweetFeeder.java so that .py file can be put under the project root
Post a Comment for "Python Importerror When Calling Python Script From Java"