Seven steps to compile Python3.5.0 from source

After a minimal install of Centos7, you would notice that your version of Python would be maybe 2.7.5 which may not be compatible with other applications you are actually using. To be updated to the latest version, one of the possibilities is to compile your own Python from Source.

python


Here are the steps that you can follow to compile your own Python. At the time, I am writing this article the latest version is Python-3.5.0. You can refer to this link for future versions.

1. Download the prerequisites. I would also recommend an update before downloading the prerequisites.

yum update -y && yum install yum-utils make wget

2. To be able to compile your Python, you will need to download some requirements which will facilitate the compilation tasks


yum-builddep python

3.Download the Python package

wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz

4.Untar your Python Package

tar xvzf Python-3.5.0.tgz

5. Get into the Package and fire the following commands

./configure
make

6. If the make process is successful, you can now start the installation with the following command

make install

7.Python-2.7 is usually the default version. You will need to specify your OS to run with the new version.


alias python='/usr/local/bin/python-3.5'

We now have the python-3.5 installed and ready for use.

Nitin J Mutkawoa https://tunnelix.com

Blogger at tunnelix.com | Founding member of cyberstorm.mu | An Aficionado Journey in Opensource & Linux – And now It's a NASDAQ touch!

You May Also Like

More From Author

2Comments

Add yours
  1. 1
    Ish Sookun

    For the last part, it’s cleaner to use sym-links than having an alias. Currently, you should be having a sym-link for ‘python’ under /usr/bin pointing to version 2.7. You can change that as follows :

    rm /usr/bin/python
    ln -s /usr/local/bin/python-3.5 /usr/bin/python

    Otherwise, if you want to keep things even cleaner, do not remove the ‘python’ sym-link and simply create one for ‘python3’ :

    ln -s /usr/local/bin/python-3.5 /usr/bin/python3

    • 2
      Kheshav Sewnundun

      You should choose the following method unless you should apply the python 3.5 system wide.

      `rm /usr/bin/python`
      `ln -s /usr/local/bin/python-3.5 /usr/bin/python`

      Just to add if user specific version of python is needed adding an alias to the user ~/bashrc is more advisable or in the PATH env.

+ Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.