Python usage notes¶
All things assume you have PATH set correctly
Which versions are available?¶
Currently, Python versions 3.6 and 3.9 are available,
python39 packages, respectively.
yum upgrade operation will not upgrade
currently-installed versions of Python to a new major
version. This would break existing apps.
Python virtual environments (highly recommended!)¶
1. Installing system-wide packages¶
yum to install any RPM-provided packages that you
may use inside your virtual environment.
2. Creating a virtual environment¶
If using Python 3.9
python3.9 -m venv --system-site-packages /path/to/venv
If using Python 3.6
python3.6 -m venv --system-site-packages /path/to/venv
3. Entering and using the virtual environment¶
To “enter” a virtual environment, run:
Once completed, you should be able to run the
pip commands. They will use the version of Python that was used to create the virtual environment.
Which Python command to use outside of a virtual environment?¶
Use the versioned python command when feasible.
It is always best to run the fully-versioned python command, which is
python3.6, since the
python3 commands may render different results depending
on what packages are installed or what the current environment
python39 is not installed
python3.6. One can alternatively use the shorthand
python3, but including the major and minor version
in the python command is more explicit and is best practice.
For instance, launch your python program via:
python39 is installed
python3.9 or simply
python, since the
Preferred Installer for Python (pip)¶
Invoke the Python interpreter command (above), followed
-m pip. For instance:
python3.9 -m pip install --upgrade xlsxwriter
Modules for accessing Db2, RPG, CL etc¶
Be sure to use the
itoolkitpackage from PyPI (installable via pip) for accessing RPG, CL, etc.
For database access with
if running on IBM i: Install the
python39-pyodbcRPM package, depending on which version of Python you are using. This will be much easier than installing with
pip, which will require you to compile these components.
If connceting remotely: install
pyodbcthrough any supported method, and use the IBM i Access ODBC driver.
(see the ODBC doc for further guidance on ODBC).
For database access with
if running on IBM i: install the
python39-ibm_dbRPM package, depending on which version of Python you are using. DO NOT INSTALL WITH
pip!! This will not work.
If connecting remotely: Install the
ibm_dbpackage in any supported fashion. Db2 Connect licensing is required.