Most of the Linux distros still shipped with Python2. Support is going to 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 configurations 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 to 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
2.Get link details from PYTHON related to the version of python you want to install. Select the Operating system and select LINUX or UNIX. Scroll down and find out the version you want to install.
Select Download tarball and right-click on it and copy the link location to provide it with wget command to get it downloaded directly to your system. It is obvious here you must need an internet access system.
3.Download the required package from the 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.
4. Extract using tar -xvzf <downloaded Package>
# tar -xvzf <Python-3-X.X.tgz> 5. 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
6. Go to the extracted folder and then follow to compile the version of python you are installing.
COMPILATION PROCESS # 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 dependencies related to running many programs for example your yum repository.
So it is important not to touch the existing version of python. You can check this before installing any version of python using the python –version command.
7.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 especially helpful for developers or administrators who want to work on python for their projects or any purpose in a Linux environment.
!!!!! Cheers !!!!!
If you like the article please share and like as much as you can to extend your support for this blog.
Other Linux How-To