Skip to content

Getting Started with Python on IBM i

Python has become an indispensable tool for modernizing applications on IBM i, thanks to its versatility, ease of learning, and extensive library support. IBM has recognized this and provides official support for Python through the Open Source Package Manager available in Access Client Solutions (ACS). This post will guide you through installing Python on your IBM i system, and demonstrate how to integrate Python scripts into your existing RPG and CLLE applications.

Installing Python via ACS’s Open Source Package Manager

IBM i’s Access Client Solutions (ACS) offers an Open Source Package Manager that simplifies the installation of Python and other open-source software directly on your IBM i system. Here’s how to get started:

  1. Open ACS and navigate to the Open Source Package Management tool.
  2. Select your system and connect to it.
  3. Look for the python39 package in the available package list. This package includes Python 3.9, which is the version recommended by IBM and comes with pip, Python’s package manager, making it easy to install additional Python libraries.
  4. Install the python39 package by selecting it and following the on-screen instructions to complete the installation process.

Once installed, you can access Python 3.9 from a PASE shell by typing python3 or python3.9.

Integrating Python with Your IBM i Applications

Python can enhance your RPG and CLLE applications by adding new functionalities that are easier to implement in Python or by leveraging Python’s vast ecosystem of libraries.

Here’s a basic example of RPG code calling a Python script. This example assumes you have a Python script named hello.py in the IFS.

**free
ctl-opt dftactgrp(*no);
dcl-pr system extproc('system');
*n pointer value options(*string);
end-pr;
dcl-s command varchar(256);
command = 'QSH CMD(''python3 /path/to/hello.py'')';
system(command);
*inlr = *on;

This RPG snippet constructs a command string to call hello.py using the system() procedure, which executes the command in a PASE environment.

Conclusion

Integrating Python into your IBM i environment opens up a world of possibilities for modernizing your applications and leveraging the extensive ecosystem of Python libraries. Whether you’re extending RPG applications or automating tasks with CLLE, Python can provide powerful functionalities to your IBM i system.