【问题标题】:How to reset the default python of Ubuntu?如何重置Ubuntu的默认python?
【发布时间】:2021-10-30 09:51:42
【问题描述】:

我已经安装了miniconda,现在需要使用ROS2,所以我在.bashrc文件中注释了conda init代码。但是如果我运行 which pythonwhich 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


【解决方案1】:
  1. 在终端检查 python 版本 - python --version
  2. 获取 root 用户权限。在终端类型上 - sudo su
  3. 记下 root 用户密码。
  4. 执行此命令切换到 python 3.6。 update-alternatives --install /usr/bin/python python /usr/bin/python3 1
  5. 检查python版本-python --version
  6. 现在一切都完成了......?

【讨论】:

  • 这并没有解决问题的具体问题
  • 我知道,我上面描述的过程是正确的,但是你不能简单地使用source。 .bashrc。您需要重新启动终端才能工作。
猜你喜欢
  • 2020-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-30
  • 2014-07-21
  • 2012-07-29
  • 1970-01-01
相关资源
最近更新 更多