Search code examples
pythonpython-3.xbashcentospython-3.5

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


Is there a way to set the Python 3.5.2 as the default Python version on CentOS 7? currently, I have Python 2.7 installed as default and Python 3.5.2 installed separately.

I used the following commands

mv /usr/bin/python /usr/bin/python-old
sudo ln -fs /usr/bin/python3 /usr/bin/python

but after that yum gives the error.

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

is there something I'm missing here?

NOTE: its the similar but opposite question of Linux CentOS 7, how to set Python2.7 as default Python version?


Solution

  • 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.