Please enable JavaScript to view this site.

Altova RaptorXML+XBRL Server 2022

Engine APIs: Python and .NET > Python API

Debugging Python Scripts in Visual Studio Code

Scroll Home Prev Top Next More

We assume an up-to-date Visual Studio Code (VS Code) intallation with the ms-python.python extension installed. Please read the official Python debug configurations in Visual Studio Code guide for a general overview.


Note the following points:


This guide uses raptorxmlxbrl-python as the command to execute RaptorXML+XBRL Server as a Python interpreter.

The raptorxmlxbrl-python executable is available in the bin folder of your RaptorXML+XBRL Server application folder.



We introduce two methods to use VS Code to debug Python scripts in RaptorXML+XBRL Server.


Method 1 also works for servers and RaptorXML Python callbacks (--script option).

Method 2 doesn't require any source code modifications. It is a modified invocation of RaptorXML. Method 2 doesn't work for servers and RaptorXML Python callbacks (--script option).

Both methods work with a standard Python interpreter and the imported RaptorXML Python module ('import altova_api.v2 as altova').


Method 1: Change your source code

Carry out the following steps:


1.Run: raptorxml-python -m pip install --upgrade debugpy

2.Add the following lines to your Python source code:


 import debugpy




3.Copy this launch configuration to VS Code launch.json (defaults will do for the above values) and select it for Run.



     "name": "Python: Remote Attach",

     "type": "python",

     "request": "attach",

     "connect": {

     "host": "localhost",

     "port": 5678


     "pathMappings": [


         "localRoot": "${workspaceFolder}",

         "remoteRoot": "."



You can also run by using the menu command Run->Add Configuration...->Python->Remote Attach with the defaults accepted.

4.Run your Python script (or RaptorXML with --script callbacks) as usual.

5.Start debugging (usually with the shortcut F5).


Method 2: Use a modified command line

Carry out the following steps:


1.Add a launch configuration (as in Method 1 above), and select it for Run.

2.Set a breakpoint in your Python script.

3.Run the command: raptorxml-python -m debugpy --listen --wait-for-client

4.Start debugging (usually with the shortcut F5).


Note:Debugging also works with containers and remote servers. You have to change the host key of the connect entry in the launch configuration. You may also use other ports as long as code or command line and launch.json have consistent values.


Setting raptorxml-python.exe as VS Code's default interpreter

It is possible to configure raptorxml-python.exe as the default Python interpreter of VS Code. Do this by adding the following to your VS Code settigs.json file:



  "python.defaultInterpreterPath": "/path/to/raptorxml-python.exe"



In this case, it is also possible to use a "Current File" launch configuration that starts the script for debugging. Consult the official VS Code documentation for details.


© 2015-2021 Altova GmbH