Oracle Linux for Python Developers

All about developing with Python on Oracle Linux

  • Home > 
  • Oracle Linux for Python Developers

About Python on Oracle Linux

There are several ways to get started with Python development on Oracle Linux. Oracle Linux yum server offers updates for system Python included with Oracle Linux as well as new versions of Python via the Software Collection Library (SCL) and EPEL (Oracle Linux 7 only). The different Python versions available and the corresponding repository and RPM names are summarized in the tables below.


Oracle Linux 7 Repository: RPM name
Python Version Base Oracle Linux Software Collection Library EPEL
3.6

ol7_software_collections: rh-python36 ol7_developer_EPEL: python36
3.5

ol7_software_collections: rh-python35

3.4

ol7_software_collections: rh-python34 ol7_developer_EPEL: python34
2.7 ol7_latest: python



Oracle Linux 6 Repository: RPM name
Python Version Base Oracle Linux Software Collection Library
3.6 ol6_software_collections: rh-python36
3.5 ol6_software_collections: rh-python35
3.4 ol6_software_collections: rh-python34
2.6 ol6_latest: python

Installing Python

Enabling Required Repositories

The installation instructions below require different Oracle Linux yum server repositories to be enabled, depending on what you are installing. For example, to enable the ol7_developer_EPEL and the ol7_oracle_instantclient repository:

$ sudo yum install -y yum-utils
$ sudo yum-config-manager --enable ol7_developer_EPEL ol7_oracle_instantclient


If your yum configuration doesn't have the required repository, grab the latest Oracle Linux yum configuration by running the these commands:

On Oracle Linux 7

$ sudo mv /etc/yum.repos.d/public-yum-ol7.repo /etc/yum.repos.d/public-yum-ol7.repo.bak
$ sudo wget -O /etc/yum.repos.d/public-yum-ol7.repo http://yum.oracle.com/public-yum-ol7.repo

On Oracle Linux 6

$ sudo mv /etc/yum.repos.d/public-yum-ol6.repo /etc/yum.repos.d/public-yum-ol6.repo.bak
$ sudo wget -O /etc/yum.repos.d/public-yum-ol6.repo http://yum.oracle.com/public-yum-ol6.repo

System Python

Python is an integral part of the Oracle Linux operating system. Oracle Linux 6 has Python 2.6 and Oracle Linux 7 has Python 2.7 already installed.

Installing Python From the EPEL for Oracle Linux 7 repository

Oracle Linux yum server hosts an EPEL (Extra Packages for Enterprise Linux) repository based on upstream Fedora EPEL. This repository includes recent versions of Python. You can install and use Python from EPEL on Oracle Linux using a virtual environment to isolate the newly installed Python interpreter, libraries and scripts from system Python.

To install and enable Python 3.6 in a virtual environment using venv, enable the ol7_developer_EPEL repo and run:

$ sudo yum install -y python36
$ python3.6 -m venv py36env
$ source py36env/bin/activate


Installing Python From the Software Collection Library

The Software Collection Library (SCL) is intended for development environments which require access to the latest features of software components such as Perl, PHP, or Python. For these environments, it's important to minimize the disruption of system processes that rely on the versions of these components. The SCL enables you to install and use several versions of the same software on a system, simultaneously, and without disruption.

To install Python 3.6 from the SCL on Oracle Linux 7, enable the ol7_software_collections repo and install scl-utils and rh-python36:

$ sudo yum-config-manager --enable ol7_software_collections
$ sudo yum -y install scl-utils rh-python36


To enable and use Python 3.6 from the SCL:

$ scl enable rh-python36 bash
$ python

cx_Oracle: Connecting Python to Oracle Database

cx_Oracle is a module that enables access to Oracle Database and conforms to the Python database API specification. For more details, see the cx_Oracle documentation

About Oracle Instant Client

cx_Oracle depends on Oracle Instant Client. On Oracle Linux yum server Oracle Instant Client 18.3 RPMs are in the ol7_oracle_instantclient and ol6_oracle_instantclient repositories. Assuming you have enabled the repository for Oracle Instant Client appropriate for your Oracle Linux release, it will be installed as a dependency. Be sure to set your environment such that cx_Oracle can find the required Oracle Instant Client libraries by following these steps. cx_Oracle is built with Oracle Client 18.3, which connects to Oracle Database 11.2 and greater. Older releases of Oracle Instant Client are available on OTN.

Installing cx_Oracle for System Python

The Oracle Linux 6 and 7 Developer repositories include cx_Oracle RPMs.* To install cx_Oracle for System Python on Oracle Linux 7, enable the ol7_developer repo and run:

$ sudo yum -y install python-cx_Oracle

*) Note for Python 2.6, use the older cx_Oracle 5.2 release.


Installing cx_Oracle for Python from EPEL

At the moment, there are no cx_Oracle RPMs for Python from EPEL. However, you can install cx_Oracle via pip. Assuming you have installed and enabled Python 3.6 from EPEL in a virtual environment and installed InstantClient, as described above.

$ python -m pip install cx_Oracle


Installing cx_Oracle for Python from the Software Collection Library (SCL)

cx_Oracle RPM built to work with SCL Python versions are named according to the format:

rh-python-<version>-python-cx_Oracle

For example, to install the matching cx_Oracle RPM for Python 3.6 from SCL:

$ sudo yum -y install rh-python36-python-cx_Oracle

Important: Configuring Your Environment for Oracle Instant Client

Finally, set up the environment so that cx_Oracle can find Oracle Instant Client libraries:

$ sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
$ sudo ldconfig

Support

Oracle Linux customers receive support for System Python and Python packages in the Software Collection Library. Community support is available in the Python and Oracle Developer Community.


References

Contact Us

software.hardware.complete
Subscribe | Careers | Contact Us | Legal Notices | Terms of Use | Your Privacy Rights