OL: How To Execute Python2 script on Oracle Linux 8
in Linux
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:
Tagged:
0