Ubuntu20.04 python3.8.10升级到python3.9
为了部署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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
2021-04-21 vs2010打开vs2017工程
2019-04-21 DevExpress中GridControl的使用笔记(转)