How to change python version in Ubuntu ?

If you have more than one python version installed like below,

$ ls -lh /usr/bin/python*
/usr/bin/python -> python2.7
/usr/bin/python2 -> python2.7
/usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
/usr/bin/python2-config -> python2.7-config
/usr/bin/python3 -> python3.6

here, as you can see we have two python versions installed, python 2.7 and python 3.6. Lets check what is our current active python version,

$ python -V
Python 2.7

Now, lets say we want to change the python version from 2.7 to 3.6 , then for your current user you can do the same by only changing environment variable from .bashrc as,

$ vim ~/.bashrc 

alias python='/usr/bin/python3.6'

Now, either reset the current terminal by typing “reset” command or close and start another terminal and if we check the python version now,

$ python -V
Python 3.6.9
Library Management System Project I... x
Library Management System Project In Python and MySQL with Source Code 2021

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development, Debugging and Performance Tools Development and Build Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web Design and Development Website Hosting Wordpress Yocto Embedded Linux