Reputation: 171
I installed Ubuntu via Virtual Machine and Python3 was pre-installed. I wanted to try out a package that was made in Python2, so I installed Python 2.7 (which became the default Python) and Anaconda2.
Now that I'm done with the package, I removed anaconda2 and I want to remove Python2, too, but I am afraid it will ruin my system if it is the default one. How do I do it in a safe way?
(base) me@me-VirtualBox:~$ whereis python
python: /usr/bin/python3.6m /usr/bin/python3.6 /usr/bin/python2.7-config /usr/bin/python /usr/bin/python2.7 /usr/lib/python3.7 /usr/lib/python3.6 /usr/lib/python3.8 /usr/lib/python2.7 /etc/python3.6 /etc/python /etc/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python2.7 /usr/include/python3.6m /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
(base) me@me-VirtualBox:~$ which python
/usr/bin/python
Upvotes: 2
Views: 4218
Reputation: 6551
You can use:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
to set it as the default, without removing python2.7
this will point the command python
to use /usr/bin/python3.6
or if update-alternatives --list python
shows more than one result, you can interactively choose which version to use with::
update-alternatives --config python
Upvotes: 4