Red Hat / CentOS versions come, by default, with an older version of Python installed:
Python version 3 is available, however, it is not included with the Red Hat and/or CentOS distribution (at the time of writing this article).# python --version Python 2.7.5
If you do wish to use Python version 3, you can download this version from iuscommunity.org, which is an online community dedicated to delivering high quality packages of newer versions of popular software.
Here's how to do that:
First, install the ius-release.rpm:
# yum install https://centos7.iuscommunity.org/ius-release.rpmNext, install Python 3.6:
# yum install python36u python36u-libs python36u-devel python36u-pipNow you can write a python script. Be sure to replace the shebang at the beginning of the script from "python" to "python3.6", like this:
If you were to just use just "python" in the shebang, then you get version 2 of Python. By specifiying "python3.6" in the shebang, you get version 3.6.:# /usr/bin/env python3.6 print('Hello')
# python --version Python 3.6.5
If you found this useful, here's more on the same topic(s) in our blog:
- Renaming a virtual machine domain with virsh
- Increase the size of a tmpfs file system
- Renew self-signed SSL Certificate
- Linux Screen
- Query NTP servers
UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.
Interested in learning more?
Interested in learning more?