Since specifying the full path of Python fixes your problem, you most likely have multiple installations of Python on your system. Rather than PYTHONPATH
being different, I suspect it is actually PATH
that is different. As a result, your command line uses the Python interpreter you intend, while Java uses another one.
To determine where this alternate install is, which -a python
may be useful, but if not, examine PATH
from inside your Java code and see if you can find Python in one of those directories.
Regardless, if you really need to specify the full Python path in Java, you should make this a configuration option. It will probably be different on different machines. Storing it in a file seems most prudent.