How to install Python 3 on LINUX
Most of the linux distros still shipped with Python2. Support is going to be end for Python2 in 2020.So it is always advisable to start using for all your purpose whatever you are going to use python. Also it is advised not to disturb your existing installation of python2 as yum works on your previous version of python or many current OS configuration depends or you can say build with your shipped version of python with OS. You have to perform this activity with elevated privilege. How to install python3 on linux is summarized below.
1.Please check if you have get wget installed on your system. If not get it installed using below.
# wget –version
If you find wget is already installed on your system no need of installing it.
# yum install wget OR # yum --enablerepo=* install wget
- Get link details from PYTHON related to version of python you want to install. Select Operating system and select LINUX or UNIX. Scroll down and find out the version you want to install. Select Download tar ball and right click on it and copy link location to provide it with wget command to get it downloaded directly to your system. It is obvious here you must need internet accessible system.
- Download required package from url you have from step 2.Go to the directory where you want to download.
# cd /opt # wget <https://www.python.org/ftp/python/3.X.X/Python-3-X.X.tgz > This will be the link location collected in step 2.
- Extract using tar -xvzf <downloaded Package>
# tar -xvzf <Python-3-X.X.tgz>
- Install dependencies required based on your yum configuration.
# yum install gcc openssl-devel bzip2-devel libffi-devel OR # yum –enablerepo=* install gcc openssl-devel bzip2-devel libffi-devel
- Go to extracted folder and then follow to compile the version of python you are installing .
# cd /opt/Python-3-X.X #./configure This will install in default directory /usr/local/bin. OR #./configure --enable-optimizations OR #./configure --prefix=/path If you want to install in any specific directory # make # make altinstall This is important to make sure not to overwrite existing python.
Important Note : Most of linux distribution still usages python 2.To avoid overwriting of existing python. There might be many other dependency related to running many programs for example your yum repository. So it is important not to touch existing version of python. You can check this before installing any version of python using python –version command.
- Create soft link for python3 and pip3 is needed and validate with below in /usr/local/bin.
# cd /usr/local/bin # ln -s python3-X.X python3 # ln -s pip-3.xx pip3
8. Validate using below
# python3 --version # pip3 --version # python --version //This is to make sure your old version is still intact.//
That,s all about how to install python3 on linux and use it for your various purpose.This is specially helpful for developers or administrators who want to work on python for their projects or any purpose on linux environment.
Cheers |||| If you like article please subscribe .