首页 > 系统相关 >Ubuntu20.04 python3.8.10升级到python3.9

Ubuntu20.04 python3.8.10升级到python3.9

时间:2023-04-21 09:46:14浏览次数:49  
标签:Ubuntu20.04 10 Python sudo version python3.8 bin python3 usr

为了部署opencv-python,安装了ubuntu20.04的虚拟机,很容易的安装了numpy、matplotlib、opencv模块。

但python是3.8.10版本,网上学习视频的版本为3.9,所以也进行了升级。

参考https://blog.csdn.net/wuxianbing2012/article/details/123532589, 完成了本次升级。

以下是参考博文的内容:

Upgrading Python in Linux

This article uses Ubuntu and its APT package manager to upgrade Python. If you are using a different Linux distribution, replace the apt command with the appropriate command featured for your package manager.

Warning: Many Linux systems have Python 2 installed as the system version. Removing Python 2 could cause a system error. If you are planning to install Python 3 on Linux, install it alongside Python 2 and invoke it with the python3 command.

1. Start by updating the repositories:

sudo apt update

2. Next, install Python 3.9 by running:

sudo apt install python3.9

When prompted, type Y to start the installation.

 

3. Once Python installs, invoke the 3.9 version by running:

python3.9

4. However, checking the installation with the python3 --version command still returns the old version. To fix this, you need to create a list of update alternatives. First, add the old version to the list with the command:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.[old-version] 1

5. Now add the new version:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2

6. Next, type the following command to configure the priority status of the versions:

sudo update-alternatives --config python3

The output displays the available choices and their assigned number (in the example below, the numbers are 0, 1, 2). Type the number of the the version you wish to use and press Enter.

7. If you are not planning to use the old version of Python, remove the symlink that contained the previous Python 3 version with:

sudo rm /usr/bin/python3

8. Then, replace the symlink with the new version:

sudo ln -s python3.9 /usr/bin/python3

9. Now, check the default version:

python3 --version

The output should confirm the successful installation and setup of the latest available version.

Why Should You Upgrade Python?

Since Python 3 was not a backward-compatible release, for a long time Python 2 remained the version of choice for those who wanted a stable development environment. Some services like Google App Engine did not support Python 3 for a long time.

However, given that the official support for the final Python 2.7 release has ended, upgrading to Python 3 is now strongly recommended. Python 3 is faster, and its syntax is more user-friendly.

If you already work with Python 3, upgrading to the latest point release gives you all the security updates and bug fixes.

 

标签:Ubuntu20.04,10,Python,sudo,version,python3.8,bin,python3,usr
From: https://www.cnblogs.com/xihong2014/p/17339186.html

相关文章

  • ABB工业控制器 UNITROL 1020 3BHE030579R0003 UNS0119A-Z,V1 3BHE030579R0001
    W;1  ⑧0③0①⑦77⑤  9ABBUNITROL10203BHE030579R0003 UNS0119A-Z,V13BHE030579R0001 DDC779BE023BHE006805R0002 XO08R21SBP260109R1001 PM866K013BSE050198R1 CI858K013BSE018135R1 PU515A3BSE032401R1 励磁控制系统的主要任务是向发电机......
  • 项目-mqtt阿里云传输图像,AD,10路输入,8路输出
     程序下载1,配置阿里云物联网平台参数 2,下载程序   3,正常运行阿里云物联网平台会显示设备在线  提示:上报开关量等数据设备发布的主题为: /a1ykoHAGGPL/${deviceName}/user/update上报摄像头数据设备发布的主题为:  /a1ykoHAGGPL/${deviceName}/use......
  • Windows 10 补丁包 msu 转 cab 用 dism 安装
    dism/online/add-package/packagepath:.\Windows6.1-KB2533623-x64.cab/norestart或dism/online/add-package/packagepath:"C:\Users\Administrator\Desktop\pack\Windows6.1-KB2533623-x64.cab"/norestart或dism/online/add-package/packagepat......
  • UVA10237 Bishops
      #include<iostream>#include<cstring>#include<queue>usingnamespacestd;constintN=2e5+2;#defineintlonglongintn,m,f1[50][2000],f2[50][2000];voidsov(){ memset(f1,0,sizeoff1);memset(f2,0,sizeoff2); f1[0][0]=f2......
  • 2023省选武汉联测10
    T1矩阵随机一个向量\(V\),判断\(V\timesA\timesB\)是否等于\(V\timesC\)即可,实质上我们在判断对于每个\(i\in[1,n]\)\(\sum_{k=1}^nV_k\sum_{p=1}^{n}A_{k,p}B_{p,i}\)是否等于\(\sum_{k=1}^{n}V_kC_{k,i}\)。code#include<cstdio>#include<vector>#incl......
  • 洛谷 P1007 独木桥
    题目背景战争已经进入到紧要时间。你是运输小队长,正在率领运输部队向前线运送物资。运输任务像做题一样的无聊。你希望找些刺激,于是命令你的士兵们到前方的一座独木桥上欣赏风景,而你留在桥下欣赏士兵们。士兵们十分愤怒,因为这座独木桥十分狭窄,只能容纳 11 个人通过。假如有 2......
  • 起泡法排序 用起泡法对10个数由小到大排序
    起泡排序是一种基础的排序算法,它通过比较相邻的两个数的大小来排序,如果前一个数比后一个数大,则交换这两个数的位置,这样一遍比较之后,最大的数就会被排在最后面,然后再重复进行这个过程,直到所有的数都被排好序为止。下面是使用起泡排序对10个数进行排序的步骤:初始化待排序数组:[5,......
  • selenium报错:This version of ChromeDriver only supports Chrome version 109 Curren
    前言:跟GPT交互,让其写一段代码,执行失败。经过排查验证,GPT写的代码没有问题,是本地环境问题。执行报错:selenium.common.exceptions.SessionNotCreatedException:Message:sessionnotcreated:ThisversionofChromeDriveronlysupportsChromeversion109Currentbrowser......
  • 1094 The Largest Generation
    Afamilyhierarchyisusuallypresentedbyapedigreetreewhereallthenodesonthesamelevelbelongtothesamegeneration.Yourtaskistofindthegenerationwiththelargestpopulation.InputSpecification:Eachinputfilecontainsonetestcase.E......
  • 1020 Tree Traversals
    Supposethatallthekeysinabinarytreearedistinctpositiveintegers.Giventhepostorderandinordertraversalsequences,youaresupposedtooutputthelevelordertraversalsequenceofthecorrespondingbinarytree.InputSpecification:Eachinput......