VS Code 在 MacOS 上未检测到 Python3 解释器

VS Code not detecting Python3 interpreter on MacOS

我刚刚将 python3 升级到 3.6(使用自制软件),现在 VS Code 似乎没有意识到这一点。当我尝试 select 我的 Python 解释器时,我看到 2.7.9 和 2.7.10(分别在 /usr/bin/usr/local/bin 中)但我没有看到 3.6.3(/usr/local/bin/python3).

它肯定在我的道路上,我知道我可以手动更新 settings.json,但我将 Python 2 和 3 用于各种项目,并通过解释器切换器使它们可用会非常有用。知道为什么 Code 没有自动检测 python3 吗?或者有没有办法强制将其添加到列表中?

想通了。 .bash_profile 修改了我安装的东西,包括以下内容:

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

我将其注释掉,重新启动 Code,现在我可以看到我所有的 Python 解释器都列出了(包括 3.6.3)。

在 VS Code 中,您可以轻松设置要用于 Python 的解释器。关注这位官方guide.

来自网站:

To select a specific interpreter, select the Python: Select Interpreter command from the Command Palette (⇧⌘P).