【发布时间】:2021-10-30 09:51:42
【问题描述】:
我已经安装了miniconda,现在需要使用ROS2,所以我在.bashrc文件中注释了conda init代码。但是如果我运行 which python 或 which python3 命令,输出仍然是 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
于是我尝试了以下方法。
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
所以你可以看到,当我运行which python3时,它仍然输出了miniconda python。
那么如何将python重置为系统默认python呢?
【问题讨论】:
-
注释行后重启终端或查看:stackoverflow.com/a/2518150/2681662
-
我已经找到了 .bashrc 文件。这是必须要做的操作,所以没有写出来。
-
我知道,我上面描述的过程是正确的,但是你不能简单地使用source。 .bashrc。您需要重新启动终端才能工作。
标签: python ubuntu anaconda ros