close

How to set Python3.5.2 as default Python version on CentOS?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to set Python3.5.2 as default Python version on CentOS in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to set Python3.5.2 as default Python version on CentOS?

  1. How to set Python3.5.2 as default Python version on CentOS?

    Option 1) Creating a soft link actually has a drawback. “yum” does not support Python3. so, if you still decide to go with symlink creation then you also need to update the /usr/bin/yum

  2. set Python3.5.2 as default Python version on CentOS

    Option 1) Creating a soft link actually has a drawback. “yum” does not support Python3. so, if you still decide to go with symlink creation then you also need to update the /usr/bin/yum

Method 1

If this

sudo ln -fs /usr/bin/python3.5 /usr/bin/python

doesn’t work (it should)

you could just add an alias into your /home/.bashrcwith this command:

alias python="/usr/bin/python3.5"

and if this does not work either you should just use virtual env. Read this page to get started.

Method 2

Option 1) Creating a soft link actually has a drawback. “yum” does not support Python3. so, if you still decide to go with symlink creation then you also need to update the /usr/bin/yum

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

And update the shebang line with #!/usr/bin/python2 in /usr/bin/yum file

Option 2) use alternatives

alternatives --install /usr/bin/python python /usr/bin/python3.x 60
alternatives --config python 

Option 3) create an alias in bash_profile

alias python="/usr/bin/python3"

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read