ubuntu 20.04系统下如何切换gcc/g++/python的版本
更新时间:2023年12月05日 08:24:53 作者:田园诗人之园
这篇文章主要给大家介绍了关于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版本内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
如何使用python-opencv批量生成带噪点噪线的数字验证码
这篇文章主要介绍了如何使用python-opencv批量生成带噪点噪线的数字验证码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-12-12
最新评论