Skip to Content
Technical Articles
Author's profile photo Denys van Kempen

BYOR: Setup Python Runtime for XSA – by the SAP HANA Academy


Last summer, Muhammad Altaf posted Getting Started with Python on SAP HANA XSA showing the steps how to install/create the Python runtime for SAP HANA XS advanced model. Judging by the number of views, this topic is of interest for the HANA development community.

Hence, “to enhance your learning experience”, we have created a tutorial video where you can see this in action using two sample code scripts.

Tutorial Video

In the video tutorial, we show how you –using SAP HANA, express edition running in Google Cloud, as example — how to prepare the OS environment, how to build Python and create the runtime. A simple test script generates a sample app to validate all is well in the best possible worlds.


Code Samples

For the sample code, see the GitHub repository:


Code Walktru

The code sample below shows how to clone the repository to your HANA development system.

sudo -i
su - hxeadm
cd $HOME
git clone
cd python
chmod u+x *.sh

Operating System Preparation

Every carpenter knows; before you can build, you need tools. An SAP HANA system, as an appliance, in express edition format, or when hardened, does not include any build tools. Not needed, overhead, potentially insecure. To build Python runtimes, you will first need to add the required packages to your system.

The SAP HANA Developer Guide documents the following packages as requirements:

zypper install tk-devel tcl-devel libffi-devel \
 openssl-devel readline-devel sqlite3-devel \
 ncurses-devel xz-devel zlib-devel

Should you still have issues with building, on a development system, consider to install the Basis-Devel pattern.

zypper search -t pattern
zypper in -t pattern Basis-Devel

If you prefer, you can use YaST2.

Create Runtime

You can download the Python source code from

The create runtime script downloads the version, configures, makes and altinstalls. The version is taken as input. We run altinstall because we do not want to update either the Linux Python release or the HANA Python version,

Note that the path here is a hardcoded HXE. If you are not using the express edition, change the path to the SID.

cd ~ ; mkdir -p builds source Downloads
wget -P ~/Downloads \
tar xzvf ~/Downloads/Python-$1$2.tgz -C ~/source
cd ~/source/Python-$1$2
./configure \
--prefix=/usr/sap/HXE/home/builds/Python-$1$2 \
--exec-prefix=/usr/sap/HXE/home/builds/Python-$1$2 \
make altinstall clean
xs create-runtime -p ~/builds/Python-$1$2
xs runtimes

Testing, Testing, 1,2,3

The test script generates the required files for a simple Hello World python script:

  • runtime.txt
  • requirements.txt
  • manifest.yaml
# create 
cat > << EOF
import os
from flask import Flask
app = Flask(__name__)
port = int(os.environ.get('PORT', 3000))
def hello():
    return "Hello World from Python $1"
if __name__ == '__main__':

To upload the app, we switch to the development space and push (upload) the app to the runtime. For housekeeping, we delete the app first (if present).

Note that “development” is one of the spaces available out-of-the-box with SAP HANA, express edition. If you are working on a regular platform edition, you might need to change the name otherwise xs push will default to the ‘SAP’ space (not recommended).

xs target -s development
xs delete -f pyapp
xs push

YouTube Playlist(s)

The tutorials has been posted to the following playlists:


For the documentation, see

Thank you for watching

The SAP HANA Academy provides free online video tutorials for the developers, consultants, partners and customers of SAP HANA.

Topics range from practical how-to instructions on administration, data loading and modeling, and integration with other SAP solutions, to more conceptual projects to help build out new solutions using mobile applications or predictive analysis.

For the full library, see SAP HANA Academy Library – by the SAP HANA Academy.

For the full list of blogs, see Blog Posts – by the SAP HANA Academy.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Yamen Gustavo Marquez Hechavarria
      Yamen Gustavo Marquez Hechavarria

      Hi  Denys van Kempen

      I'am trying to follow your Tutorial but I'am not able to doit because HANA Express (On premise VM) doesn’t come with any repositories configured by default and i'am not sure which repos to use. Can you please point me in the right direction?

      Thank in advance

      Author's profile photo Denys van Kempen
      Denys van Kempen
      Blog Post Author

      Hi Yamen,

      We covered this in this video: register VM

      Once you have registered the VM, the default repositories will be available.

      The cloud-based VMs (Google, Azure, etc.) include an OS license (for which you pay the IaaS provider).

      Author's profile photo Eik Sunke
      Eik Sunke

      Hi Denys,

      I am having an issue when I try to push an python 3.x app using the SP4 buildpack and your script to create the runtime directly on the HXE host, When pushing the app, the system tries to compile with 2.x python version in the staging process. Due to this it gives an error that ssl is not available. When I install python 3 on the hxe host and update alternatives to switch from python 2 to python3 for the python command, the app deployes and runs just fine.

      However, my understanding is that the runtime should not be affected by os configurations or installations, Am I missing something while creating the runtime?




      Author's profile photo Denys van Kempen
      Denys van Kempen
      Blog Post Author

      Hi Eik,

      Thank you for your comment. I would have to carve out some time to look into this. In the meantime, you could consider to post this comment as a question on the forum It might very well be that somebody else already faced this issue and managed to solve it.


      Author's profile photo Eik Sunke
      Eik Sunke

      And so I did:

      Author's profile photo Sergio Guerrero
      Sergio Guerrero

      thank you for sharing these steps Denys, I am stuck on the step that creates the runtime. I am getting an error: could not find ~/builds/Python-3.9.1/lb/python3.9/site-packages/pks_resources


      any idea where this file comes from? The rest of the steps were working correctly on a suse linux vmware workstation 16


      Thank you in advance

      Author's profile photo Denys van Kempen
      Denys van Kempen
      Blog Post Author

      Hi Sergio,

      Looks like a Java program is looking for a file/directory but finds nothing. A

      Which command triggers this error?

      Author's profile photo Sergio Guerrero
      Sergio Guerrero

      xs create-runtime command

      Author's profile photo Denys van Kempen
      Denys van Kempen
      Blog Post Author

      No idea what might cause this. Would have to look into the log files, try to reproduce this issue, etc.

      The xs create-runtime command (apparently triggering a Java application for the build) is specific to XSA. There is no equivalent cf create-runtime command and I could not find any reference to similar issues.

      Did you verified the steps documented the Developer Guide? Maybe there are some changes in the procedure for the latest release.

      For the previous question, I recommended to post the question to the forum but noticed there was no response as of yet. 

      Have you reached out to SAP Support? 

      Maybe Muhammad Altaf knows?

      Author's profile photo Sergio Guerrero
      Sergio Guerrero

      thanks Denys, I had posted a question already. I had tried version 3.9.1 and also 3.4.10 with similar errors of missing files.