How to install Python in different directory leaving the default untouched

Often, we face situations where there is more up to date Python version required for certain applications to work, however, our hands get tied at the same time because we cannot make changes  to the current (outdated or lower) version of Python installed in the system. So what do we do? How to install Python in different directory leaving the default untouched? Luckily, we have tools and utilities to achieve this goal and the task is fairly simple. We will use the latest version of Python 3.6.0 Let’s get started then.


Download the Source GZipped Folder

First of all, download the source files using wget or curl utility.



Extract the files and change directory cd to extracted folder.


Run Configuration Utility

The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available, and finds out whatever it needs to know to use those dependencies.

If you want to install the python in a different directory i.e. /usr/local/python3, you will require the --prefix  flag.


./configure --prefix=/usr/local/python3


Once the process is completed, run the following command:


make && make install


That’s it. when the process is finished, you will have a latest version installed in the /usr/local/python3 directory. You can confirm it by running the following command:

[root@server Python-3.6.0]# /usr/local/python3/bin/python3 -V
Python 3.6.0


As you can see, in the output above, we have latest version of Python installed in a different directory and we left the default python as it is. Additionally, you can create a symbolic link in/usr/bin/ t0 point to your latest python.

[root@server ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@server ~]# python3 -V
Python 3.6.0


System still have it’s default Python installed

[root@server ~]# python -V
Python 2.6.6

Hope this has been informative.

Share your thoughts