Skip to content

[Linux] Download, Install And Switch The Python Version

There are many of versions of Python, the different versions have different functions. But the more important thing is, some useful packages are worked on the specific versions.

Today I want to note how to install different python versions and switch them in our Linux system.


Download and Installation

First we must to confirm the python version we need, and we can use the following url to check all the version python have: https://www.python.org/ftp/python/

Python versions

For example, I want to download the python 3.6.9:

wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar -zxvf Python-3.6.9.tgz
cd Python-3.6.9


The I make it:

./configure --with-ssl --prefix=/usr/local/python3
make
sudo make install

How to Switch Python Version

After installation, we need to delete the old symbol link of python, and point to the new version path we installed (Both python and pip).

sudo rm /usr/bin/python3
sudo rm /usr/bin/pip3

sudo ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
sudo ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3


After switching, remember to use -V or -version argument to check the current python version:

python3 -V
pip3 -V

Output:

Python 3.6.9
pip 18.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

References


Read More

Leave a ReplyCancel reply

Exit mobile version