Install Python 3.5.1 on CentOS/RHEL 7/6
Python 3.x is a new version of the language, which is incompatible with the 2.x line of releases. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. You can also know more features in python 3.5
Step #1 Require Package
Firstly make sure that all require packages installed on your system. Use following command to install all packages:
# yum install gcc
Step #2 Download Python 3.5
Download Python using following command and you can also download latest version from python official site.
# cd /opt # wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
Step #3 Extract Archive and Compile
Use below commands to extract Python source code and compile it on your system using altinstall.
# tar xzf Python-3.5.1.tgz # cd Python-3.5.1 # ./configure # make altinstall
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
Step #4 Check the Python Version
Check the latest version installed of python using below command
# python3.5 -V Or # python3.5 --version
Thank you! This is really helpful 🙂
Running “# python3.5 –version” might return the below error:
bash: python3.5: command not found
In that case, just run “# python3 –version” and the output should be as below:
If you want to use `pip` then the following packages will also need to be installed before you run the `./configure` command
yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
yum install zlib-devel zlib