python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > ubuntu切换gcc/g++/python版本

ubuntu 20.04系统下如何切换gcc/g++/python的版本

作者:田园诗人之园

这篇文章主要给大家介绍了关于ubuntu 20.04系统下如何切换gcc/g++/python版本的相关资料,文中通过代码介绍的非常详细,对大家学习或者使用ubuntu具有一定的参考借鉴价值,需要的朋友可以参考下

前言

当系统同时存在gcc-9以及gcc-10时该如何切换让当前的系统gcc版本指向gcc-9或是gcc-10呢?g++也同样如此。

面临更严重问题的python更是如此,ubuntu 目前默认安装的python版本是2.7,而我们经常使用的版本为3.xx。

1 安装gcc/g++/python

同时安装gcc/g+±9,gcc/g+±10,python2/3

sudo apt-get install update

sudo apt install gcc-9
sudo apt install g++-9

sudo apt install gcc-10
sudo apt install g++-10

sudo apt install python
sudo apt install python3

2 设置gcc/g++/python的备选项

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 2

3 选择当前系统要使用的gcc/g++/python版本

3.1 切换gcc/g++/python版本

sudo update-alternatives --config gcc
sudo update-alternatives --config g++
sudo update-alternatives --config python

3.2 切换示例

以gcc为例

$ sudo update-alternatives --config gcc
[sudo] password for test: 
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path             Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-10   10        auto mode
* 1            /usr/bin/gcc-10   10        manual mode
  2            /usr/bin/gcc-9    9         manual mode

Press <enter> to keep the current choice[*], or type selection number: 0
$

总结 

到此这篇关于ubuntu 20.04系统下切换gcc/g++/python版本的文章就介绍到这了,更多相关ubuntu切换gcc/g++/python版本内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文