Fedora Linux 中的 Python 3.10 测试版
Python
![](/data/attachment/album/202106/29/221603gdqc9cq9cjcjjuxg.jpg)


Python 开发者已经发布了 Python 3.10.0 的三个测试版本。现在，你可以在 Fedora Linux 中试用最新的版本尽早用 3.10 测试你的 Python 代码，为 10 月份的 3.10.0 最终版本做好准备。


### 在 Fedora Linux 上安装 Python 3.10


如果你运行 Fedora Linux，你可以用 `dnf` 从官方仓库安装 Python 3.10：



```
$ sudo dnf install python3.10

```

你可能需要启用 `updates-testing` 仓库来获得最新的预发布版本：



```
$ sudo dnf install --enablerepo=updates-testing python3.10

```

随着更多的测试版和候选版 [发布](https://www.python.org/dev/peps/pep-0619/)，Fedora 包将得到更新。不需要编译你自己的 Python 开发版本，只要安装它就可以获得最新。从第一个测试版开始，Python 开发者不会再增加新的功能了。你已经可以享受所有的新东西了。


### 用 Python 3.10 测试你的项目


运行 `python3.10` 命令来使用 Python 3.10，或者用 [内置的 venv 模块 tox](https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html) 或用 [pipenv](https://fedoramagazine.org/install-pipenv-fedora/) 和 [poetry](https://python-poetry.org/) 创建虚拟环境。下面是一个使用 `tox` 的例子：



```
$ git clone https://github.com/benjaminp/six.git
Cloning into 'six'...
$ cd six/
$ tox -e py310
py310 run-test: commands[0] | python -m pytest -rfsxX
================== test session starts ===================
platform linux -- Python 3.10.0b3, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
collected 200 items

test_six.py ...................................... [ 19%]
.................................................. [ 44%]
.................................................. [ 69%]
.................................................. [ 94%]
............                                       [100%]

================== 200 passed in 0.43s ===================
________________________ summary _________________________
  py310: commands succeeded
  congratulations :)

```

如果你在 Fedora Linux 上发现了 Python 3.10 的问题，请 [在 Fedora 的 bugzilla 上提交 bug 报告](https://bugzilla.redhat.com/buglist.cgi?component=python3.10&product=Fedora) 或在 [Python 的问题追踪](https://bugs.python.org/) 上提交。如果你不确定这是否是 Python 的问题，你可以 [通过电子邮件或 IRC 直接联系 Fedora 的 Python 维护者](https://fedoraproject.org/wiki/SIGs/Python#Communicate) 。


### Python 3.10 中的新内容


参见 [Python 3.10 的全部新闻列表](https://docs.python.org/3.10/whatsnew/3.10.html)。例如，你可以尝试一下 [结构模式匹配](https://www.python.org/dev/peps/pep-0634/)：



```
$ python3.10
Python 3.10.0b3 (default, Jun 17 2021, 00:00:00)
[GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> point = (3, 10)
>>> match point:
...     case (0, 0):
...         print("Origin")
...     case (0, y):
...         print(f"Y={y}")
...     case (x, 0):
...         print(f"X={x}")
...     case (x, y):
...         print(f"X={x}, Y={y}")
...     case _:
...         raise ValueError("Not a point")
...
X=3, Y=10
>>> x
3
>>> y
10

```

敬请期待 [Fedora Linux 35 中的 python3 —— Python 3.10](https://fedoraproject.org/wiki/Changes/Python3.10)！




---


via: <https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/>


作者：[Miro Hrončok](https://fedoramagazine.org/author/churchyard/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The Python developers have already released three beta versions of Python 3.10.0. You can try the latest one in Fedora Linux today! Test your Python code with 3.10 early to be ready for the final 3.10.0 release in October.

## Install Python 3.10 on Fedora Linux

If you run Fedora Linux, you can install Python 3.10 from the official software repository with *dnf*:

$ sudo dnf install python3.10

You might need to enable the *updates-testing* repository to get the very latest pre-release:

$ sudo dnf install --enablerepo=updates-testing python3.10

As more betas and release candidates [will be released](https://www.python.org/dev/peps/pep-0619/), the Fedora package will receive updates. No need to compile your own development version of Python, just install it and have it up to date. The Python developers will add no new features starting with the first beta; you can already enjoy all the new things.

## Test your projects with Python 3.10

Run the *python3.10* command to use Python 3.10 or create virtual environments with the [builtin venv module, tox](https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html) or with

[pipenv](https://fedoramagazine.org/install-pipenv-fedora/)and

[poetry](https://python-poetry.org/). Here’s an example using

*tox*:

$ git clone https://github.com/benjaminp/six.git Cloning into 'six'... $ cd six/ $ tox -e py310 py310 run-test: commands[0] | python -m pytest -rfsxX ================== test session starts =================== platform linux -- Python 3.10.0b3, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 collected 200 items test_six.py ...................................... [ 19%] .................................................. [ 44%] .................................................. [ 69%] .................................................. [ 94%] ............ [100%] ================== 200 passed in 0.43s =================== ________________________ summary _________________________ py310: commands succeeded congratulations :)

If you find a problem with Python 3.10 on Fedora Linux, please do [file bug reports at Fedora’s bugzilla](https://bugzilla.redhat.com/buglist.cgi?component=python3.10&product=Fedora) or in the [Python’s issue tracker](https://bugs.python.org/). If you aren’t sure if it is a problem in Python, you can [contact the Fedora’s Python maintainers](https://fedoraproject.org/wiki/SIGs/Python#Communicate) directly via email or IRC.

## What’s new in Python 3.10

See the [full list of news in Python 3.10](https://docs.python.org/3.10/whatsnew/3.10.html). You can, for example, try out [structural pattern matching](https://www.python.org/dev/peps/pep-0634/):

$ python3.10 Python 3.10.0b3 (default, Jun 17 2021, 00:00:00) [GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> point = (3, 10) >>> match point: ... case (0, 0): ... print("Origin") ... case (0, y): ... print(f"Y={y}") ... case (x, 0): ... print(f"X={x}") ... case (x, y): ... print(f"X={x}, Y={y}") ... case _: ... raise ValueError("Not a point") ... X=3, Y=10 >>> x 3 >>> y 10

And stay tuned for [Python 3.10 as python3 in Fedora Linux 35](https://fedoraproject.org/wiki/Changes/Python3.10)!

## Katsuharu Tanaka

Python3.10 doesn’t seem to be supported by Pandas, which is often used for Data Science, but I’m very interested in API stability and def method stability.

Thank you for providing me with a valuable news article.

## Janil Garcia

Have you tried using pandas with it?

I just successfully created a new virtualenv with Python 3.10 and pandas is working just fine for me.

I believe Python 3.10 is API compatible with 3.9, just changing internal details in some libraries and maybe adding new optional parameters. Most libraries will be unaffected by the change.

The new syntax constructs were also additive, so nothing should be broken by them.

## Václav Tengler

nejde to

## Alex

Why python3.10 is normal package instead of the module :(?

## Miro Hrončok

Because modules are generally not parallel installable and if we want to make them so we would be packaging a “normal package” like this one into a module for no benefit. Maintaining modular packages is needlessly complex and using them from other parts of the Fedora project is almost impossible.

## SergMx

It’s a shame they buried SCLO. This technology had no problem keeping five PYTHONs in one system.

But they went down the road of simplification. One module in one container …

## Miro Hrončok

You can have many different Pythons in Fedora on one system. See https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html

## Mx

Thank you. Good resource.

But why do you think there is a section about mod_wsgi?

With SCLO I had no problem using 2 and 3 at once.

venv = chroot only python.

sclo = system level chroot.

## Dilord

Me gustaría aprender algo básico sobre Python como lenguaje de programación y ver algunos ejemplos sencillos.