Create a Python execution environment on IBM i

Quickly install Python with yum on IBM i

Now that yum can be used, IBM i can easily create various open source execution environments, not limited to Python. Please refer to the article here (Using yum with IBM i) for the procedure to install yum in advance.

Python2 is installed with yum when it is installed, so from here on, we will set up the environment for Python3.

You can use the ACS GUI or the SSH CLI to install Python3.

Method 1: Install Python 3 with ACS GUI

Start ACS and open Open Source Package Management from the Tools menu. image.png Specify the System to install Python3 and USRPRF and click [OK] to proceed. スクリーンショット 2019-11-14 10.21.29.png You can see a list of available packages on the Available packages tab. It seems that Python3 packages are being added from time to time. image.png First, I selected two packages ** python3 ** and ** python3-pip ** and pressed the [install] button. image.png A separate window will open and the ** yum install ** command will be executed. You can see that another package with a dependency is also selected at the same time. Run the installation with ** y **. image.png Confirm that the installation is complete. image.png You can easily introduce Python with the ACS GUI. If you have other required packages, you can install them by the same procedure.

Method 2: Install with yum command from SSH client

Not only can you use the ACS GUI, but you can of course operate with the SSH client CLI as you would with Linux. Connect to ibmi with an SSH terminal.

$ ssh user@ibmi

Use bash.

$ bash

Check python3 related packages.

bash-4.4$ yum list | grep python3
python3.ppc64                                3.6.9-1                   @ibm
python3-pip.noarch                           9.0.1-2                   @ibm
python3-setuptools.noarch                    36.0.1-2                  @ibm
python3-wheel.noarch                         0.29.0-2                  @ibm
python3-Pillow.ppc64                         5.0.0-4                   ibm
python3-asn1crypto.noarch                    0.24.0-0                  ibm
python3-bcrypt.ppc64                         3.1.4-5                   ibm
python3-cffi.ppc64                           1.11.5-2                  ibm
python3-cryptography.ppc64                   2.2.2-4                   ibm
python3-dateutil.noarch                      2.7.5-0                   ibm
python3-devel.ppc64                          3.6.9-1                   ibm
python3-ibm_db.ppc64                         2.0.5.9-0                 ibm
python3-idna.noarch                          2.8-0                     ibm
python3-itoolkit.ppc64                       1.6.1-0                   ibm
python3-lxml.ppc64                           4.2.1-3                   ibm
python3-numpy.ppc64                          1.15.4-0                  ibm
python3-pandas.ppc64                         0.22.0-4                  ibm
python3-psutil.ppc64                         5.5.1-0                   ibm
python3-pycparser.ppc64                      2.19-1                    ibm
python3-pynacl.ppc64                         1.2.1-3                   ibm
python3-pytz.noarch                          2018.5-2                  ibm
python3-pyzmq.ppc64                          17.1.2-0                  ibm
python3-rpm.ppc64                            4.13.0.1-17               ibm
python3-scikit-learn.ppc64                   0.19.1-6                  ibm
python3-scipy.ppc64                          1.1.0-0                   ibm
python3-six.noarch                           1.10.0-0                  ibm
python3-tkinter.ppc64                        3.6.9-1                   ibm

Let's introduce additional numpy and pandas.

bash-4.4$ yum install python3-numpy python3-pandas
Setting up Install Process

(Omission)

===================================================================================================================
 Package                          Arch                    Version                      Repository             Size
===================================================================================================================
Installing:
 python3-numpy                    ppc64                   1.15.4-0                     ibm                   6.3 M
 python3-pandas                   ppc64                   0.22.0-4                     ibm                    20 M
Installing for dependencies:
 libblas3                         ppc64                   3.8.0-0                      ibm                   173 k
 libcblas3                        ppc64                   3.8.0-0                      ibm                    49 k
 libgcc-aix                       fat                     6.3.0-24                     ibm                   472 k
 libgfortran3                     ppc64                   6.3.0-24                     ibm                   1.0 M
 liblapack3                       ppc64                   3.8.0-0                      ibm                   3.4 M

Transaction Summary
===================================================================================================================
Install       7 Packages

Total download size: 31 M
Installed size: 147 M
Is this ok [y/N]: y

(Omission)

Installed:
  python3-numpy.ppc64 0:1.15.4-0                          python3-pandas.ppc64 0:0.22.0-4

Dependency Installed:
  libblas3.ppc64 0:3.8.0-0    libcblas3.ppc64 0:3.8.0-0  libgcc-aix.fat 0:6.3.0-24  libgfortran3.ppc64 0:6.3.0-24
  liblapack3.ppc64 0:3.8.0-0

Complete!

I could easily add it with the yum command. With an SSH client, you can manage an open source environment with the yum command without being aware that it is IBM i.

Python startup confirmation

Try launching Python 3 with the ssh client.

bash-4.4$ python3
Python 3.6.9 (default, Oct 31 2019, 11:30:53)
[GCC 6.3.0] on aix7
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import pandas as pd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/QOpenSys/pkgs/lib/python3.6/site-packages/pandas/__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['pytz', 'dateutil']

When I imported ** pandas **, I got an error saying that ** pytz ** and ** dateutil ** are missing. Since it is Python, I will consider adding it with pip, but in IBM i, it may be provided as a yum package, so check yum first.

>>> exit()
bash-4.4$ yum list | grep python3
(Omission)
python3-dateutil.noarch                      2.7.5-0                   ibm
(Omission)
python3-pytz.noarch                          2018.5-2                  ibm

Both were in yum, so install with yum.

bash-4.4$ yum install python3-dateutil python3-pytz

Start Python3 again and try importing pandas.

bash-4.4$ python3
Python 3.6.9 (default, Oct 31 2019, 11:30:53)
[GCC 6.3.0] on aix7
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import pandas as pd
>>> data = pd.Series([1.0, 2.4, 5.3, 7], index=['a', 'b', 'c', 'd'])
>>> data
a    1.0
b    2.4
c    5.3
d    7.0
dtype: float64
>>> exit()

You now have a Python 3 execution environment on IBM i.

Finally

With IBM i, you can easily prepare your Python environment. Since it supports yum, it can basically be managed by CLI, but it seems to be IBM i that ACS also provides a GUI interface. You can run Python on a PC, but if you set up IBM i as a Python environment, it will be easier to handle IBM i data, and it will be easier for team development.

In the method of this article, the execution environment of Python3 is created in the root environment, but if you use chroot, you can virtualize the environment like a container, so you can choose the combination of packages according to your purpose and clean the root environment. You can also take advantage of open source while preserving it.

Next time, I would like to run jupyter notebook after creating a virtual environment using chroot.

Recommended Posts

Create a Python execution environment on IBM i
Create a Python environment on Mac (2017/4)
Create a python environment on centos
Create a python environment on your Mac
Create a Python environment
Simply build a Python 3 execution environment on Windows
[Venv] Create a python virtual environment on Ubuntu
Create a Python virtual development environment on Windows
Create a comfortable Python 3 (Anaconda) development environment on windows
I made a Python3 environment on Ubuntu with direnv.
Create a decent shell and python environment on Windows
Create a Python development environment on OS X Lion
Building a Python environment on Mac
Building a Python environment on Ubuntu
Create a Linux environment on Windows 10
Build a python3 environment on CentOS7
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Create a virtual environment for python on mac [Very easy]
Build a python environment on MacOS (Catallina)
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
[Python] Create a Batch environment using AWS-CDK
I want to build a Python environment
Creating a python virtual environment on Windows
I installed Kivy on a Mac environment
Create an OpenCV3 + python3 environment on OSX
I built a TensorFlow environment on windows10
Build a Python + OpenCV environment on Cloud9
Create a Python environment for professionals in VS Code on Windows
I tried to create a server environment that runs on Windows 10
Create a Python execution environment for Windows with VScode + Remote WSL
[Mac] Create a Python3 execution environment from the fully initialized state
Create a Vim + Python test environment in 1 minute
How to create a Python virtual environment (venv)
Create a Python module
Build a python environment with ansible on centos6
I want to create a window in Python
Build a Python environment on Mac (Mountain Lion)
Create a virtual environment with conda in Python
Create a python3 build environment with Sublime Text3
Build a Python development environment on your Mac
[Python] Create an asynchronous task execution environment + monitoring environment
Set up a Python development environment on Marvericks
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Building a Python environment on a Sakura VPS server
Create a Python3.4 + Nginx + uWSGI + Flask Web application execution environment with haste using pyenv on Ubuntu 12.04
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Build a Python development environment on Raspberry Pi
Build a python execution environment with VS Code
I want to create a nice Python development environment for my new Mac
Until a Python inexperienced engineer builds a TensorFlow execution environment + comfortable coding environment on Mac
When I tried to create a virtual environment with Python, it didn't work
Virtualize (isolate) IBM i python development environment with chroot
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Notes on creating a python development environment on macOS Catalina
Create a python development environment with vagrant + ansible + fabric
Build a GVim-based Python development environment on Windows 10 (1) Installation
How to build a Django (python) environment on docker
Build a Python environment on your Mac using pyenv
Procedure for building a CDK environment on Windows (Python)