mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-07 22:11:09 +08:00
183 lines
5.7 KiB
Markdown
183 lines
5.7 KiB
Markdown
[#]: subject: "How to Install Python 3.11 in Ubuntu and Other Related Linux"
|
||
[#]: via: "https://www.debugpoint.com/install-python-3-11-ubuntu/"
|
||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||
[#]: collector: "lkxed"
|
||
[#]: translator: " "
|
||
[#]: reviewer: " "
|
||
[#]: publisher: " "
|
||
[#]: url: " "
|
||
|
||
How to Install Python 3.11 in Ubuntu and Other Related Linux
|
||
======
|
||
|
||
**Planning to get Python 3.11 installed for your project work? Here’s how to install Python 3.11 in Ubuntu and related distros.**
|
||
|
||
![][1]
|
||
|
||
Python 3.11 was released on Oct 25, 2022, and claims to be 10-60% faster than the prior [Python 3.10][2] version.
|
||
|
||
As always, the feature and improvement list are significantly high in 3.11. Here’s a brief.
|
||
|
||
- Error tracebacks are not more definite, which gives you an exact statement that causes the error.
|
||
- Introduction of exception groups and new except* syntax
|
||
- You can add custom text in the base expression for better error handling in your code.
|
||
- Introduction of Variadic generic to allow array-like structure in numerical Python libraries )such as NumPy)
|
||
- Dictionary type TypedDict gets improvement where you can now specify whether individual dictionary items are mandatory or optional.
|
||
- Introduction of Self annotation, which allows classes to return their own type instance.
|
||
|
||
And many more, which you can read in detail on the official [3.11 highlights page][3].
|
||
|
||
### Current Python versions in Linux Distros
|
||
|
||
[Ubuntu 22.04 LTS][4] have Python 3.10, whereas the recently released [Ubuntu 22.10 Kinetic Kudu][5] also have the same. However, Kinetick Kudu will probably feature 3.11 within a few weeks.
|
||
|
||
Also, [Fedora 37][6] (planned for Nov 1) already has the Python 3.11 RC2 and will get the version.
|
||
|
||
So, if you are running Ubuntu 22.04 LTS, [Linux Mint 21][7] or any Ubuntu-LTS-based distros, here’s how you can install Python 3.11 via a PPA.
|
||
|
||
**Note**: Use this method with caution. Make sure you know what you are doing because replacing the base Python version of a Linux distribution may cause an unstable system. Many default applications and packages depend on the 3.10 version.
|
||
|
||
### How to install Python 3.11 in Ubuntu and related distros
|
||
|
||
- Open a terminal prompt and add the following PPA.
|
||
|
||
```
|
||
sudo add-apt-repository ppa:deadsnakes/ppa
|
||
```
|
||
|
||
- Refresh the cache using the below command.
|
||
|
||
```
|
||
sudo apt update
|
||
```
|
||
|
||
- And install Python 3.11 using the below command.
|
||
|
||
```
|
||
sudo apt install python3.11
|
||
```
|
||
|
||
![Install Python 3.11 in Ubuntu 22.04 LTS][8]
|
||
|
||
Install Python 3.11 in Ubuntu 22.04 LTS
|
||
|
||
### Set Default Python Versions
|
||
|
||
In theory, you can install multiple versions of Python in Linux distros, but the default can only be one version. Setting up Python 3.11 as default requires some additional steps. Follow along.
|
||
|
||
However, before you do that, make sure you know which applications depend on Python 3.10. You can easily find it out using `apt-cache rdepends` command as below.
|
||
|
||
```
|
||
debugpoint@debugpoint-22-04:~$ apt-cache rdepends python3.10
|
||
python3.10
|
||
Reverse Depends:
|
||
python3.10-dbg
|
||
python3.10-venv
|
||
python3.10-full
|
||
libpython3.10-testsuite
|
||
idle-python3.10
|
||
idle-python3.10
|
||
python3.10-minimal
|
||
python3.10-doc
|
||
python3.10-dev
|
||
python3
|
||
virtualbox
|
||
python3.10-venv
|
||
python3.10-full
|
||
libpython3.10-testsuite
|
||
kitty
|
||
idle-python3.10
|
||
idle-python3.10
|
||
python3.10-minimal
|
||
python3.10-doc
|
||
python3.10-dev
|
||
python3.10-dbg
|
||
python3-uno
|
||
python3-all
|
||
python3.10-dbg
|
||
virtualbox
|
||
stimfit
|
||
python3.10-venv
|
||
python3.10-full
|
||
python3-stfio
|
||
python3-escript-mpi
|
||
python3-escript
|
||
python3-csound
|
||
plasma-firewall
|
||
pitivi
|
||
obs-studio
|
||
liferea
|
||
libpython3.10-testsuite
|
||
libglib2.0-tests
|
||
kitty
|
||
idle-python3.10
|
||
idle-python3.10
|
||
cluster-glue
|
||
atac
|
||
rhythmbox-plugins
|
||
python3.10-minimal
|
||
python3.10-doc
|
||
python3.10-dev
|
||
python3
|
||
python3-uno
|
||
python3-all
|
||
gedit
|
||
```
|
||
|
||
#### Use Python 3.11 as the default Python3
|
||
|
||
- First, check the current default version using the below command from the terminal.
|
||
|
||
```
|
||
python3 --version
|
||
```
|
||
|
||
- Use `update-alternatives` to create symbolic links to `python3`
|
||
|
||
```
|
||
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
|
||
```
|
||
|
||
```
|
||
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
|
||
```
|
||
|
||
- And choose which one to use as Python3 via the command:
|
||
|
||
```
|
||
sudo update-alternatives --config python3
|
||
```
|
||
|
||
![Setting up default python version to 3.11][9]
|
||
|
||
Setting up default python version to 3.11
|
||
|
||
Now you can start using the latest Python in your current Ubuntu version for your work/study. You switch to the stock version using the above commands and change the versions at any time.
|
||
|
||
If you switch to 3.11 using the above install method, then make sure you check all the necessary apps to see whether they are working fine.
|
||
|
||
Finally, do let me know in the comment box if you run into problems.
|
||
|
||
--------------------------------------------------------------------------------
|
||
|
||
via: https://www.debugpoint.com/install-python-3-11-ubuntu/
|
||
|
||
作者:[Arindam][a]
|
||
选题:[lkxed][b]
|
||
译者:[译者ID](https://github.com/译者ID)
|
||
校对:[校对者ID](https://github.com/校对者ID)
|
||
|
||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||
|
||
[a]: https://www.debugpoint.com/author/admin1/
|
||
[b]: https://github.com/lkxed
|
||
[1]: https://www.debugpoint.com/wp-content/uploads/2022/10/py3112204-1024x576.jpg
|
||
[2]: https://www.debugpoint.com/install-python-3-10-ubuntu/
|
||
[3]: https://docs.python.org/3.11/whatsnew/3.11.html
|
||
[4]: https://www.debugpoint.com/ubuntu-22-04-review/
|
||
[5]: https://www.debugpoint.com/ubuntu-22-10/
|
||
[6]: https://www.debugpoint.com/fedora-37/
|
||
[7]: https://www.debugpoint.com/linux-mint-21-review/
|
||
[8]: https://www.debugpoint.com/wp-content/uploads/2022/10/Install-Python-3.11-in-Ubuntu-22.04-LTS.jpg
|
||
[9]: https://www.debugpoint.com/wp-content/uploads/2022/10/Setting-up-default-python-version-to-3.11.jpg
|