在 PyCharm 中更改 Python 版本

Manav Narula 2022年5月17日
在 PyCharm 中更改 Python 版本

与其他所有编程语言一样,Python 会定期维护和更新。添加了新功能,并且每次更新都会进行更改。因此,在特定 Python 版本上运行的代码可能不适用于其他版本。

PyCharm 是一个广泛使用的 Python IDE。我们可以在 IDE 中配置 Python Interpreter 来切换 Python 版本。本教程将展示如何实现这一点。

首先,我们需要确保我们需要的版本的解释器安装在 PyCharm 上。然后,我们需要从文件菜单中选择设置选项。从那里,我们需要选择首选项选项。在此,我们需要选择 Project Interpreter。选择此选项后,我们将找到 Python Interpreter 选项,我们可以选择所需的解释器版本并应用更改。

我们也可以通过选择 Run 菜单中的 Edit Configurations 选项并在 Python Interpreter 中选择所需的版本来更改此设置。

在 Pycharm 2019.1+ 以后,状态栏中添加了一个新功能。此功能包括解释器的版本并查看正在使用的版本。我们可以点击这个快速切换不同的版本。如果状态栏不可见,我们可以使用 Windows 的 Ctrl+Shift+A 组合或 ++A 适用于 Mac。

Author: Manav Narula
Manav Narula avatar Manav Narula avatar

Manav is a IT Professional who has a lot of experience as a core developer in many live projects. He is an avid learner who enjoys learning new things and sharing his findings whenever possible.

LinkedIn