I tried executing a python command using ksh in SAP BODS script to run a program called "zzz.py" in the BODS server:
print(exec('ksh', '-c "python --version"', 8));
print(exec('ksh', '-c "python zzz.py"', 8));
However, upon executing the script, I got the following output:
3850 2990602048 PRINTFN 11/2/2017 4:26:17 PM 0: Python 2.7.9
3850 2990602048 PRINTFN 11/2/2017 4:26:17 PM 1: Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix>
3850 2990602048 PRINTFN 11/2/2017 4:26:17 PM Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] ImportError: No module named site
While I proceeded to add the export PYTHONHOME=/usr/bin/python
, and executed the printenv
command, the PYTHONHOME path is not shown.
I went ahead to use SSH to access the server via PuTTy, and executing the command works perfectly. However, when running the python --version
command, it shows that my version in 2.7.5 as opposed to the one shown in BODS. I tried adding the PYTHONHOME path as well, but it did not help in the BODS (and instead i cannot run the python command in my SSH session, which of course i went to unset
it and SSH session works normally now)
May I seek some help in this? THANKS!
Managed to solve this:
When executing from BODS, a different user is being used (as opposed to root which was being used for SSH). Had to set "export LD_LIBRARY_PATH=/usr/local/lib" before executing python and it works.