Playing with Python on IBM i

Share on Social Media

One of the great things about IBM i is the amount of Open Source technologies that have been added over the years. This means that if you know any of them, you can write applications within the platform.

So I decided to go ahead and try with Python, since it’s powerful, fast, open and it’s great for Data Science, something I am getting into.

Now, I’ve been struggling to find the required steps needed to connect to the IBM i platform, install Python and actually write some code to test. Everything I found was targeted to people with some IBM i knowledge. I contacted people from the community to help me understand what to do: Mike Pavlak, Holger Scherer from PUB400, Liam Allan and Trevor Perry. I am really blown away for the patience, support and willingness to help they always had with me. Of course this is not more than the IBM i community showing how great it is.

I needed to understand what was involved in the process. I had questions. I still do:

  • Why would I want to write Python on IBM i?
  • How can I write Python code on IBM i?
  • How do I install Python on IBM i?

This is my research and please correct me in the comments if you have a different idea about my answers.

Why would I want to write Python on IBM i?

IBM i is an operating environment running on IBM’s Power Systems, as defined by Trevor Perry here. In the series of interviews “Learning from Champions”, “What is IBM i” was my first question. With minor differences, all of the answers talked about how solid, modern, reliable and powerful this platform is for the business world. IBM i includes file serving, integrated database, security, work management, virtualization, auditing, storage management and application serving, among other things.

But here is the thing: if you are a developer most likely you are not choosing the platform; instead it’s being chosen for you. Let’s say you get hired by a company for which the development platform is a Power Systems running IBM i: you will need to know how to work with it. Let’s move on then.

How can I write Python code on IBM i?

I’ve personally tried with Eclipse IDE, Visual Studio Code and Sublime Text.

Eclipse IDE: It’s a free editor that can be downloaded from here. Once it’s installed, you need to download PyDev, which is a Python IDE for Eclipse.
Once this is done, you’ll need to connect to the IBM i partition you want to connect to. If you don’t have an IBM i partition and you are following this to learn, you can go to pub400.com (a public IBM i server) and sign up for a partition. In order to connect you need the server address (in this case would be pub400.com, a username and password, which will be given to you once you register.
Once you have your credentials, in Eclipse IDE’s top menu you need to click on “Window”, then “Show View” then “Other…”, select “Remote Systems” and finally click on “Open”.

This will show you a new tab in the left hand side area of the Eclipse IDE.


From here you want to click on the “New Connection” arrow to expand. From there you will double click on “SSH Only”. This new window will pop up:

For “Host name“, use “PUB400.COM” or the host name you work with if you don’t need to sign up for PUB400.
For “Connection name” type anything you want. This will be the name of your connection when you start working with it, so you may want to choose a name that you can relate to this new connection. In my case I typed “PUB2” for testing purposes.
For “Description“, enter anything to describe the connection. I typed “Test”.
Leave the “Verify host name” checked. The wizard will ping the server to ensure it’s there. Click “Finish”.

Now what you will see in the left hand side is the new connection.

Double click on “My Home” and you will be prompted for your User ID and Password. These are the credentials that either you received from PUB400 or previously had from another IBM i server.
From here you can start writing sophisticated Python code, like I did in the code below:

Now you can run your remote code (remember, this code is sitting on the IBM i File System) locally (to make it clear: the code is remote but you are running it locally on your computer).

Most likely there are many other things we could do with Eclipse and I will post about them as I discover them. But for the moment this is it.

For Visual Studio Code and Sublime Text 3 (and probably many other editors I haven’t tried with) you will need to mount a remote folder on your local machine. I have followed these instructions to do so on my Mac, and I believe you can follow these instructions if you have Windows.

Once you have your remote folder mounted, you can work with either IDE pretty much in the same way you would do with files sitting on your local hard drive: open your “first.py” file with Sublime Text or Visual Studio Code from the mounted remote folder.

If you want to run the code, here is how you do it with Visual Studio Code:

Once again, we look at the console to check the result:


Here is how we do it with Sublime Text 3:

Once Python is selected, you can command + B (Mac) or ctrl + B (Windows) and the result will show in the console:

How do I install Python on IBM i?

Please note that I didn’t have the need to install Python since it was already installed on the two IBM i partitions I have access to and since they are shared partitions, I cannot reinstall it. This means that I wasn’t able to document the steps.
However, should you have the need to install Python, I will add the links with instructions below.

I am aware of two different ways of installing Python:
1. Using Access Client Solutions (ACS) or
2. Using Yum, which is an open source package manager.

Using Access Client Solutions (ACS)

Open ACS and connect to the IBM i server you need to install Python to.
Go to”Tools” and then “Open Source Package Management”.

Once there, you will see 3 tabs:

Go to “Available Packages” and look for Python3. Since I have Python already installed, what you see here is a Photoshopped image. You should see something similar if you don’t have Python installed.
From this screen, select “python3” and click “Install”.

You can find great step by step instructions here as well.

Using Yum

Since I have Python already installed, I haven’t gone through the process myself, however I have read instructions from different places (I’ll add the links).

First of all, you need to know if yum is installed. In order to do so we can use again the Access Client Solutions (ACS). Open ACS, go to “Tools” then “Open Source Package Management” and search for “yum” in the “Installed Packages” tab. If yum shows there, then it’s installed. Click on it and then click on “Information”. This will give you the path where yum is installed.
However, if yum is not on this list, move to the “Available Packages” tab. Once you find it, click on “install” and follow through.

Once yum is installed, from the Access Client Solutions click on “SSH Terminal”.
Once here, you’ll have to move to the path where yum is installed. In my case it was on /QOpenSys/pkgs/bin.

cd /QOpenSys/pkgs/bin

Hit enter and then type

yum install python3

This will install Python 3 via yum. From here you can then choose your IDE and start writing your Python code on IBM i!

There is a fantastic post from Stephanie Rabbani about this same topic.

This has been a large post for me, lots of research and learning, which is the whole idea. I am loving this platform and my whole idea is to keep documenting every single step I take to learn more about it.

If you are in the situation where you need to learn from scratch, I truly hope this blog is helpful. It’s being written with you and me – beginners – in mind.

Please feel free to comment, throw ideas and corrections, they are always welcome.

Thank you.


Share on Social Media

2 thoughts on “Playing with Python on IBM i

  1. Have you had any luck on PUB400 with the “ibm_db_dbi” and “itoolkit” packages for working with the underlying DB2 system with Python? I don’t see them installed, and also the python3 interpreter (python3.6) cannot find them.

    1. Hello Bryan, sorry for the long delay in getting back to you.
      I haven’t worked with it but I take your question as a next step.
      I am still quite new to the platform so my steps are baby steps while I work on other fronts at the same time.
      As soon as I have an answer, I’ll come back to post it.

      I thank you for the question, it helps me to continue looking to understand the platform.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.