python安装卡在core interpreter_选择并安装 Python 解释器 - Visual Studio | Microsoft Docs

本文介绍了如何在 Visual Studio 2017 及更高版本中安装和选择 Python 解释器,包括默认安装、手动安装和使用 '添加环境' 对话框。Visual Studio 自动检测注册表中的 Python 解释器,支持 Python 2.7 及 3.5 及以上版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装 Python 解释器Install Python interpreters

06/05/2019

JoshuaPartlow.png?size=32

olprod.png?size=32

本文内容

默认情况下,在 Visual Studio 2017 和更高版本中安装 Python 开发工作负载也会同时安装 Python 3(64 位)。By default, installing the Python development workload in Visual Studio 2017 and later also installs Python 3 (64-bit). 可以根据需要选择安装 32 位和 64 位版本的 Python 2 和 Python 3,并安装 Miniconda (Visual Studio 2019) 或者 Anaconda 2/Anaconda 3 (Visual Studio 2017),如安装中所述。You can optionally choose to install 32-bit and 64-bit versions of Python 2 and Python 3, along with Miniconda (Visual Studio 2019) or Anaconda 2/Anaconda 3 (Visual Studio 2017), as described in Installation.

或者,也可以从“添加环境” 对话框中安装标准 Python 解释器。Alternately, you can install standard python interpreters from the Add Environment dialog. 在“Python 环境”窗口或 Python 工具栏中选择“添加环境”命令,选择“Python 安装”选项卡,指示安装哪个解释器,并选择“安装”。Select the Add Environment command in the Python Environments window or the Python toolbar, select the Python installation tab, indicate which interpreters to install, and select Install.

除了 Visual Studio 安装程序,还可以手动安装下表列出的任何解释器。You can also manually install any of the interpreters listed in the table below outside of the Visual Studio installer. 例如,如果在安装 Visual Studio 之前安装了 Anaconda 3,则不需要通过 Visual Studio 安装程序再次进行安装。For example, if you installed Anaconda 3 before installing Visual Studio, you don't need to install it again through the Visual Studio installer. 例如,如果在 Visual Studio 安装程序中尚无可安装的更高版本,也可以手动安装解释器。You can also install an interpreter manually if, for example, a newer version of available that doesn't yet appear in the Visual Studio installer.

备注

Visual Studio 支持 Python 版本 2.7 以及版本 3.5 和更高版本。Visual Studio supports Python version 2.7, as well as version 3.5 and greater. 可以使用 Visual Studio 编辑在 Python 其他版本中编写的代码时,这些版本不受官方支持,IntelliSense 和调试等功能可能无法正常工作。While it is possible to use Visual Studio to edit code written in other versions of Python, those versions are not officially supported and features such as IntelliSense and debugging might not work.

对于 Visual Studio 2015 及更早版本,必须手动安装其中一个解释器 。For Visual Studio 2015 and earlier, you must manually install one of the interpreters.

Visual Studio(所有版本)通过检查注册表(根据 PEP 514 - Windows 注册表中的 Python 注册)自动检测各个已安装的 Python 解释器及其环境。Visual Studio (all versions) automatically detects each installed Python interpreter and its environment by checking the registry according to PEP 514 - Python registration in the Windows registry. Python 安装通常位于 HKEY_LOCAL_MACHINE\SOFTWARE\Python(32 位)和 HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python(64 位)下的“PythonCore”(CPython) 和“ContinuumAnalytics”(Anaconda) 等分发节点中 。Python installations are typically found under HKEY_LOCAL_MACHINE\SOFTWARE\Python (32-bit) and HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python (64-bit), then within nodes for the distribution such as PythonCore (CPython) and ContinuumAnalytics (Anaconda).

如果 Visual Studio 并未检测到安装的环境,请参阅手动标识现有环境。If Visual Studio does not detect an installed environment, see Manually identify an existing environment.

Visual Studio 在Python 环境”窗口中显示所有已知环境,并自动检测现有解释器的更新。Visual Studio shows all known environments in the Python Environments window, and automatically detects updates to existing interpreters.

解释器Interpreter

说明Description

最常用的“本机”解释器,32 位和 64 位版本可用(建议使用 32 位)。The "native" and most commonly-used interpreter, available in 32-bit and 64-bit versions (32-bit recommended). 包括最新的语言功能、最大的 Python 包兼容性、完整的调试支持以及与 IPython 的互操作。Includes the latest language features, maximum Python package compatibility, full debugging support, and interop with IPython. 请注意,Visual Studio 2015 及更早版本不支持 Python 3.6+,并且会生成“不支持 Python 版本 3.6”之类的错误 。Note that Visual Studio 2015 and earlier do not support Python 3.6+ and can give errors like Unsupported python version 3.6. 请改用 Python 3.5 或更早版本。Use Python 3.5 or earlier instead.

Python 的 .NET 实现,32 位和 64 位版本可用,提供 C#/F#/Visual Basic 互操作、对 .NET API 的访问、标准 Python 调试(但不是 C++ 混合模式调试)和混合 IronPython/C# 调试。A .NET implementation of Python, available in 32-bit and 64-bit versions, providing C#/F#/Visual Basic interop, access to .NET APIs, standard Python debugging (but not C++ mixed-mode debugging), and mixed IronPython/C# debugging. 但 IronPython 不支持虚拟环境。IronPython, however, does not support virtual environments.

Python 提供技术支持的开放式数据科学平台,包括最新版本的 CPython 和大部分难以安装的包。An open data science platform powered by Python, and includes the latest version of CPython and most of the difficult-to-install packages. 如果你不能做出决定,我们建议使用它。We recommend it if you can't otherwise decide.

Python 的高性能跟踪 JIT 实现,适用于长时间运行的程序以及识别性能问题但找不到其他解决方法的情况。A high-performance tracing JIT implementation of Python that's good for long-running programs and situations where you identify performance issues but cannot find other resolutions. 可与 Visual Studio 配合使用,但对高级调试功能的支持有限。Works with Visual Studio but with limited support for advanced debugging features.

Java 虚拟机 (JVM) 上 Python 的实现。An implementation of Python on the Java Virtual Machine (JVM). 与 IronPython 类似,Jython 中运行的代码可与 Java 类和库交互,但可能无法使用许多适用于 CPython 的库。Similar to IronPython, code running in Jython can interact with Java classes and libraries, but may not be able to use many libraries intended for CPython. 可与 Visual Studio 配合使用,但对高级调试功能的支持有限。Works with Visual Studio but with limited support for advanced debugging features.

对于想要提供新形式的 Python 环境检测的开发人员,请参阅 PTVS 环境检测 (github.com)。Developers that want to provide new forms of detection for Python environments, see PTVS Environment Detection (github.com).

移动解释器Move an interpreter

如果将现有解释器移到使用文件系统的新位置,则 Visual Studio 不会自动检测更改。If you move an existing interpreter to a new location using the file system, Visual Studio doesn't automatically detect the change.

如果最初通过“Python 环境”窗口指定解释器的位置,则使用该窗口中的“配置”选项卡来编辑其环境,以确定新位置 。If you originally specified the location of the interpreter through the Python Environments window, then edit its environment using the Configure tab in that window to identify the new location.

如果使用安装程序安装解释器,则使用以下步骤在新位置重新安装解释器:If you installed the interpreter using an installer program, then use the following steps to reinstall the interpreter in the new location:

将 Python 解释器还原到其原始位置。Restore the Python interpreter to its original location.

使用其安装程序卸载解释器,这会清除注册表项。Uninstall the interpreter using its installer, which clears the registry entries.

在所需位置重新安装解释器。Reinstall the interpreter at the desired location.

重新启动 Visual Studio,它应该会自动检测新位置来代替原来的位置。Restart Visual Studio, which should auto-detect the new location in place of the old location.

遵循此过程,确保标识解释器位置的注册表项正确更新,以供 Visual Studio 使用。Following this process ensures that the registry entries that identify the interpreter's location, which Visual Studio uses, are properly updated. 使用安装程序还可以处理可能存在的任何其他副作用。Using an installer also handles any other side effects that may exist.

另请参阅See also

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值