• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Guru: Getting Started With Python On IBM i

    June 10, 2019 Stephanie Rabbani

    Python is one of my favorite open-source languages. I’ve used it to build web applications, utilities, and diverse tools such as a web server monitor and an automated application testing suite. In this article, I’ll show you how to install Python on IBM i and create your first program.

    Why Python? For several reasons.

    • You can use Python to do some cool processing on your system. Graphical application development, games, data analysis, and web development are all Python’s strengths.
    • Coding in Python is easy, relatively speaking. The syntax is easy to learn, dropping the formal verbosity found in traditional coding languages.
    • It’s a deeper well for new talent. This means it’s more welcoming to beginners, as indicated by Python’s consistent rank as one of the fastest growing languages.
    • Python unlocks new ways to optimize and streamline workflow and operations, evolving IBM i so it keeps its throne over the next few decades. Open source is the foundation of the cloud computing world; it’s why IBM has embraced open source technologies in its Power roadmap. Modern languages will influence and evolve how your company interacts with its data.

    The Basics Of Python

    Python uses very simple syntax:

    • It uses spacing instead of brackets to denote code blocks, such as if statements and loops.
    • It’s case-sensitive.

    There’s no need to explicitly declare variables. Variables are declared when you assign a value. Values are assigned to variables using a single equal sign (=).

    habs = 24
    

    Python is case-sensitive, so Habs is not the same as habs. Comments are preceded with a hash mark (#) and can follow on the same line of code.

    habs = 24	#number of Stanley cups won by Montreal
    

    Or . . .

    habs = 24
    #number of Stanley cups won by Montreal
    if habs < 25:
    print("they’ve been golfing since 1994")
    if habs > 24:
    print("I'll be old or dead before this is true, so you'll likely never see this message")
    

    Your first Python program can include a built-in Python server.

    run(host='0.0.0.0', port=8228, debug=True, reloader=True)
    

    Setting Up Python On IBM i

    Getting started with Python on IBM i is dead simple. Just follow two simple steps.

    Step 1: Download and install YUM, an open source package manager.

    IBM delivers open source software via YUM, so it’s where you’ll find Python 3 and other open source goodies.

    Download YUM here: https://www-01.ibm.com/support/docview.wss?uid=nas8N1022619. Your system must be at IBM i 7.2 or later.

    Important Note: The most secure, stable way is to run YUM and Python is in SSH. IBM i’s Business Architect of open source technologies, Jesse Gorzinski, explains the fundamentals of shells in this blog post, including how to choose and set your shell.

    It’s also possible to install via QP2TERM().

    Step 2: Install the Python package with YUM

    • From Access Client Solutions, IBM’s free GUI for managing your IBM i:
      • Go to the IBM i Tools menu Open Source Package Management.
        • At this point, a list of currently installed Open Source packages will be displayed. If Python3 isn’t there, click the “Available Packages” tab.
        • If you skipped the first step, clicking Open Source Package Management in the Tools menu will present a message asking if you’d like to install YUM.

     

    • From the Command line it’s as simple as typing:
    yum install python3
    

    Now you can download python packages by pip3 install.

    Python programs are typically .py extensions.

    Optional Step

    If you want to avoid having to specify the full path to Python every time you run it, add /QOpenSys/pkgs/bin to your path.

    You can use this shell command to change the path:

    PATH=/QOpenSys/pkgs/bin:$PATH
    export PATH
    

    Your First Python program

    1. From the 5250 command line, run the Edit File (EDTF) command to open the IFS editor.
    EDTF STMF('/home/steph/hello.py')
    

    From the blank EDTF screen, press F15=Services to go to EDTF Options, where you should change the CCSID of hello.py to 1208 (Unicode), a Python-friendly encoding, as shown below:

    1. On the first line, type the following:
    print("hello world")
    

    Press F3 to save and exit.

    1. CALL QP2TERM or ssh to access PASE, and key the following command to run the Python program.
    python3 /home/steph/hello.py

    An IBM Champion and senior consultant for Seiden Group, Stephanie has developed web applications on the IBM i for over 15 years. Her expertise encompasses PHP, Python, DB2, SQL, RPG, Git, WebSmart, IBM i integration techniques and more. She develops a broad range of applications—shopping carts, ordering, warehousing, dashboards, mobile/responsive applications, Salesforce integration, and more—for small to Fortune 500 companies.

    
    

    RELATED STORIES

    Club-Seiden Python for IBM i Examples

    IBM i Open Source

    IBM i Access Client Solutions

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: 400guru, FHG, Four Hundred Guru, IBM i, Power Systems, Python, Yum

    Sponsored by
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Watch this webinar where we showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch the replay now!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Server Buying Cools, But It’s Cool – Don’t Panic It’s Getting Cloud-i In Here

    6 thoughts on “Guru: Getting Started With Python On IBM i”

    • Mike Krebs says:
      June 10, 2019 at 10:09 am

      The steps 2 and 3 in “your first python program” appear to need lowercase (print instead of Print and python3 instead of Python3). And the EDTF command created the file in CCSID 37 which apparently python3 does not understand directly. In EDTF, I used Services (F15) to change the file CCSID to 1208 (UTF-8) and then I was able to run the program.

      Reply
      • alanseiden says:
        June 19, 2020 at 12:23 pm

        Thanks, Mike! The article has been updated as you suggested, including setting CCSID=1208.

        Reply
    • Mark Soulje says:
      June 10, 2019 at 1:41 pm

      thank you for the article. used this as my excuse to try the Python waters again. don’t know if it’s helpful to anyone else. had to use python3 instead of Python3 and changed the line of code from Print to print to get it to work.

      Reply
      • se yarbrough says:
        January 10, 2020 at 9:32 am

        Great read..thanks for the article..

        Reply
      • alanseiden says:
        June 19, 2020 at 12:24 pm

        Mark, you’re right. Those “P”s have been made lowercase now.

        Reply
    • john says:
      September 25, 2020 at 6:51 am

      What an half baked article is this ?

      yum install python3

      Now you can download python packages by pip3 install.,.. what does this step says.. where to download python3 packages, and where does it go /

      Reply

    Leave a Reply Cancel reply

TFH Volume: 29 Issue: 35

This Issue Sponsored By

  • New Generation Software
  • RPG & DB2 Summit
  • Profound Logic Software
  • ARCAD Software
  • WorksRight Software
  • OCEAN User Group

Table of Contents

  • IBM i Roadmap Promises A Long Ride, Few Bumps
  • It’s Getting Cloud-i In Here
  • Guru: Getting Started With Python On IBM i
  • Server Buying Cools, But It’s Cool – Don’t Panic
  • The Transition To RHEL 8 Begins On Power Systems
  • Situation Wanted: DBCS Conversion Expert For Apps Sold Into Japan

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • POWERUp 2025 –Your Source For IBM i 7.6 Information
  • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
  • Guru: Creating An SQL Stored Procedure That Returns A Result Set
  • As I See It: At Any Cost
  • IBM i PTF Guide, Volume 27, Number 19
  • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
  • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
  • i-Rays Brings Observability To IBM i Performance Problems
  • Another Non-TR “Technology Refresh” Happens With IBM i TR6
  • IBM i PTF Guide, Volume 27, Number 18

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle