Skip to Content

Unable to execute python command in SAP BODS

Nov 02, 2017 at 09:26 AM


avatar image

I tried executing a python command using ksh in SAP BODS script to run a program called "" in the BODS server:

print(exec('ksh','-c "python --version"',8));

print(exec('ksh','-c "python"',8));

However, upon executing the script, I got the following output:

38502990602048  PRINTFN 11/2/20174:26:17 PM    0:Python2.7.9

38502990602048  PRINTFN 11/2/20174:26:17 PM    1:Couldnot find platform independent libraries <prefix>Couldnot find platform dependent libraries <exec_prefix>

38502990602048  PRINTFN 11/2/20174: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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Tommy Yong Nov 09, 2017 at 06:20 AM

Managed to solve this by:

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.

10 |10000 characters needed characters left characters exceeded
Arun Sasi Nov 03, 2017 at 05:18 AM

Is your Data Services Job server installed on Linux or Windows Server?

Never worked on executing a shell command to execute the python code. Have you tried to execute the exec() function below

Before executing the exec() command try setting the environment variable for the BODS user profile(user who runs the job)

export PYTHONHOME=/usr/bin/python

Try to declare the location of the Python .py file in a substitution parameter

[$$PythonLibPath]= /usr/bods/pythonfiles;

/* Print the output of exec() functon*/

print(exec('ksh','-c python [$$PythonLibPath]/',8));

**what is -c option used for?

kindly follow the below links for reference


Arun Sasi

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for your reply!

It seems like there is a need to declare LD_LIBRARY_PATH instead, which solves the issue.