Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Vitaliy-R
Developer Advocate
Developer Advocate
4,547

The Python Tools extension, which enhances the Python coding experience, was introduced in SAP Business Application Studio (referred to as "BAS" below) exactly two years ago. Here are my notes from using it.

This post is not a tutorial or a comprehensive guide to best practices. It’s a collection of personal notes, which I hope you find helpful when working with Python in BAS. The focus here is on running Python code in BAS, not on deploying to SAP BTP runtimes like Cloud Foundry (CF) or Kyma. This is when you are usually working on Machine Learning or AI projects in BAS, like during SAP CodeJams.

I assume you're not an absolute beginner with SAP Business Application Studio—or at least you're familiar with Visual Studio Code.

For the examples in this post, I’ll be using the SAP Business Application Studio available in the SAP BTP Trial environment.

 

Python runtime

In SAP Business Application Studio, the dev space includes a system-level Python 3 binary at /bin/python3, which is primarily intended for OS-level scripts and tooling. This version is tied to the base container image and is only updated when the image itself is refreshed.

Managing Python versions

For application development, developers typically use user-managed Python runtimes. Since January 2024, you can select the Python version with which you want to work.

VitaliyR_0-1752787857188.png

SAP Business Application Studio uses asdf to allow you to select which runtime versions to install and use for developing your application. You can check this in the BAS terminal with asdf current python.

VitaliyR_0-1752826029935.png

By default, SAP Business Application Studio provides only one officially supported Python version.

If you need another version of Python, you can install it with asdf install python <version>. If you want the latest minor version, then use latest:, like asdf install python latest:3.12 in the case of the 3.12 version of Python.

VitaliyR_1-1752826587342.png

At the time of writing this post, the asdf version used in BAS is 0.12.0. This version uses the asdf global and asdf local commands to set the actual runtime version. If you refer to the asdf documentation, these commands have been replaced with asdf set, so don't get confused.

VitaliyR_4-1752832090379.png

Runtime management from the command palette

You can also install different versions from the command palette. Select > Runtime: Install, then Python, and the version you want to install. To set the default version of Python for execution, use the command > Runtime: Set Default.

VitaliyR_3-1752831488109.png

These commands are provided by the built-in BAS Framework extension.

VitaliyR_2-1752831268028.png

You can now run your Python programs in BAS...

...using a version of Python accordingly to your requirements.

VitaliyR_0-1752833019314.png

 

Design-time

Being a fork of Visual Studio Code - Open Source ("Code - OSS")—SAP Business Application Studio provides basic support for Python files and Jupyter notebooks out of the box.

VitaliyR_0-1752835179123.png

BAS additional extension "Python Tools"

To improve your Python coding experience, SAP Business Application Studio provides an additional extension called "Python Tools". This extension includes IntelliSense, formatting, linting, and debugging support for Python files and Jupyter notebooks.

To add "Python Tools" to your BAS dev space, go to the configuration of a stopped or a newly created dev space, and select Python Tools from Additional SAP Extensions.

VitaliyR_1-1752833807354.png

Upon activation, you should see additional extensions listed now as built-in in BAS.

VitaliyR_1-1752835746649.png

Note that BAS installs its extensions from Open VSX, an open-source registry for VS Code extensions. VS Code's Python extension is available at: https://open-vsx.org/extension/ms-python/python.

You can see Python extensions in the file system:

ls -lad /extbin/local/openvscode-server/extensions/ms-py*

VitaliyR_2-1752837415019.png

These are extensions selected and integrated by the BAS product team at SAP.

Additional notes:

You can install other versions of the same extensions directly from https://open-vsx.org/, but there is no guarantee that they have been tested and will properly work with BAS. First of all, the extension version installed directly from the marketplace should be compatible with the version of SAP Business Application Studio (or the "Code—OSS" to be more precise).

For example, at the time of writing this post, the version of the Python extension at the VSX marketplace is 2025.04...

VitaliyR_0-1752844419611.png

which is compatible with version 1.94.0 of Code-OSS and therefore BAS: https://github.com/microsoft/vscode-python/blob/v2025.4.0/package.json#L50 

VitaliyR_1-1752844619669.png

Usage of the Python extension in BAS

Upon installation of the Python extension in BAS, you can:

1/ Execute Python extension's commands from the palette:
VitaliyR_3-1752839390743.png

2/ Trigger an execution of a program from the editor:
VitaliyR_4-1752839526904.png

...which you can configure by editing the python.terminal settings:

VitaliyR_0-1753218387860.png

3/ modify its @ext:ms-python.python settings:
VitaliyR_5-1752839680256.png

 

Python virtual environments

To run your code, you usually need additional Python packages, such as the Python machine learning client for SAP HANA (hana-ml) or SAP Cloud SDK for AI (Python).

If you have experience with Python, then you already know all the advantages of using virtual environments. Although you can think of BAS devspace as an isolated project development environment, there is a good reason to use Python virtual environments there, as I already explained in Persisting Python environment in SAP Business Application Studio.

An additional reason to use a virtual environment is if you plan to test or run your project using different versions of Python managed by asdf. Each of the installed versions of Python will use their own location to store packages:

VitaliyR_1-1753198029018.png

You should be ready to work with Python in SAP Business Application Studio now! 

Please share your tips in the comments!

In my other blog posts, I focused on:
🪐 Using Jupyter in SAP Business Application Studio, and
🔨 Using conda-forge in SAP Business Application Studio.

------

-Vitaliy, aka @Sygyzmundovych