You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

OL: How To Execute Python2 script on Oracle Linux 8

Applies to:

Oracle Linux - Version 8

Goal

Some Python script imported from older versions of Oracle Linux might still use Python2.

Python2 is not compatible with Python3, which is the default for Oracle Linux 8 and newer.

Solution

Oracle Linux 8 still includes Python2 on repository [ol8_appstream].

To install Python2:

$ dnf install python2

(It might also need to install some python2-* libraries.)

Note that python2 cannot be the default python, because some system components require python3.

The recommendation is to set the shebang in python script to:

#!/usr/bin/python2

Python2 can be set as the default python for a particular user, by running:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!