2

I have installed miniconda, and I need to use ROS2 now, so I have commented the conda init code in .bashrc file. But if I run which python or which python3 command, the output is still the miniconda python.

yan@yan-Precision-7920-Tower:~$ which python
/home/yan/miniconda3/bin/python

yan@yan-Precision-7920-Tower:~$ which python3
/home/yan/miniconda3/bin/python3

So I tried the following methods.

yan@yan-Precision-7920-Tower:~$ ls /usr/bin/python*
/usr/bin/python     /usr/bin/python3.8           /usr/bin/python3-coverage    /usr/bin/python-argcomplete-check-easy-install-script3
/usr/bin/python2    /usr/bin/python3.8-config    /usr/bin/python3-futurize    /usr/bin/python-argcomplete-tcsh3
/usr/bin/python2.7  /usr/bin/python3.8-coverage  /usr/bin/python3-pasteurize
/usr/bin/python3    /usr/bin/python3-config      /usr/bin/python3-pbr

yan@yan-Precision-7920-Tower:~$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python3 (python3) in auto mode

yan@yan-Precision-7920-Tower:~$ sudo update-alternatives --config python3
There is only one alternative in link group python3 (providing /usr/bin/python3): /usr/bin/python3.8
Nothing to configure.

yan@yan-Precision-7920-Tower:~$ sudo update-alternatives --set python3 /usr/bin/python3.8

yan@yan-Precision-7920-Tower:~$ which python3
/home/yan/miniconda3/bin/python3

So you can see that when I run which python3, it still output the miniconda python.

So how to reset the python to the system default python?

Yan Wen
  • 39
  • 1
  • 3
  • Restart your terminal after commenting the lines or see: https://stackoverflow.com/a/2518150/2681662 – MSH Oct 30 '21 at 09:53
  • I have sourced the .bashrc file. This is an operation that must be done, so I didn't write it out. – Yan Wen Oct 30 '21 at 13:28
  • I knew, the process I described above is correct, but you can't simply use source. bashrc. You need to restart terminal to work. – Yan Wen Oct 30 '21 at 13:35

1 Answers1

-1
  1. Check python version on terminal - python --version
  2. Get root user privileges. On terminal type - sudo su
  3. Write down the root user password.
  4. Execute this command to switch to python 3.6. update-alternatives --install /usr/bin/python python /usr/bin/python3 1
  5. Check python version - python --version
  6. Now all done...