Skip to main content

Introduction and Prerequisites

Embedded Python allows you to use Python as a native option for programming InterSystems IRIS applications. If you are new to Embedded Python, read Introduction to Embedded Python, and then read this document for a deeper dive into Embedded Python.

While this document will be helpful to anyone who is learning Embedded Python, some level of ObjectScript familiarity will be beneficial to the reader. If you are a Python developer who is new to InterSystems IRIS and ObjectScript, also see the Orientation Guide for Server-Side Programming.

Recommended Python Version

The version of Python recommended when using Embedded Python depends on the platform you are running. In most cases, this is the default version of Python for your operating system. See Other Supported Features for a complete list of operating systems and the corresponding supported version of Python.

Note:

On some operating systems, you can override the recommended version of Python using the Flexible Python Runtime feature.

On Microsoft Windows, the InterSystems IRIS installation kit installs the correct version of Python (currently 3.9.5) for use with Embedded Python only. If you are on a development machine and want to use Python for general purposes, InterSystems recommends downloading and installing this same version from https://www.python.org/downloads/Opens in a new tab.

Many flavors of UNIX-based operating systems come with Python installed. If you need to install it, use the version recommended for your operating system by your package manager, for example:

  • Ubuntu: apt install python3

  • Red Hat Enterprise Linux or Oracle Linux: yum install python3

  • SUSE: zypper install python3

  • macOS: Install Python 3.11 using HomebrewOpens in a new tab.

    brew install python@3.11

    You should also make sure you are using the current version of OpenSSL:

    brew unlink openssl
    brew install openssl@3
    brew link --force openssl@3
    
  • AIX: Install Python 3.9.18+ using dnf (dandified yum) from the AIX Toolbox for Open Source SoftwareOpens in a new tab

If you get an error that says “Failed to load python,” it means that you either don’t have Python installed or an unexpected version of Python is detected on your system. Check Other Supported Features and make sure you have the required version of Python installed, and if necessary, install it or reinstall it using one of the above methods. Or, override the recommended Python version by using the Flexible Python Runtime feature. (Not available on all platforms.)

If you are on a platform that does not support the Flexible Python Runtime feature, your computer has multiple versions of Python installed, and you try to run Embedded Python from the command line, irispython will run the first python3 executable that it detects, as determined by your path environment variable. Make sure that the folders in your path are set appropriately so that the required version of the executable is the first one found. For more information on using the irispython command, see Start the Python Shell from the Command Line.

Required Service

To prevent IRIS_ACCESSDENIED errors while running Embedded Python, enable %Service_Callin. In the Management Portal, go to System Administration > Security > Services, select %Service_CallIn, and check the Service Enabled box.

Flexible Python Runtime Feature

On some operating systems, you can override the version of Python recommended for Embedded Python by using the Flexible Python Runtime feature. This is useful if you are writing code or using a package that depends on a version of Python other than the one recommended. You must use a version of Python that is the same or greater than your operating system's default version. For example, Red Hat Enterprise Linux 9 comes with Python 3.9, so on that operating system you must use version 3.9 or higher.

The configuration setting PythonRuntimeLibrary specifies the location of the Python runtime library to use when running Embedded Python. This version of the library overrides the default version of the library used when launching Embedded Python.

To specify a Python runtime library:

  1. In the Management Portal, go to System Administration > Configuration > Additional Settings > Advanced Memory.

  2. In the PythonRuntimeLibrary row, click Edit.

  3. Enter the location of the Python runtime library you want to use.

    For example: /usr/lib/x86_64-linux-gnu/libpython3.11.so.1

    This location will vary based on your operating system, Python version, and other factors. The example shown here is for Python 3.11 on Ubuntu 22.04 on the x86 architecture.

  4. Click Save.

For more information, see PythonRuntimeLibrary.

Note:

The Flexible Python Runtime feature is not supported on all operating systems. See Other Supported Features for a complete list of platforms that support the feature.

If you install a new version of Python and cannot find the Python runtime library, you may need to install it separately. For example, to install the Python 3.11 runtime library on Ubuntu 22.04: apt install libpython3.11.

For more details on how to configure this feature, see Use the Flexible Python Runtime Feature.

FeedbackOpens in a new tab