














使用VS Code运行Python代码必须安装Python解释器。VS Code本身不包含Python解释器,需要手动安装并配置。
安装Python
从Python官网( www.python.org )或Anaconda(https://www.cnblogs.com/emanlee/p/12381558.html) 下载安装Python。Anaconda包含100多个常用库,安装更便捷。
配置VS Code

Ctrl+Shift+~ ),输入python命令检查版本。 
选择解释器
通过 Ctrl+Shift+P 打开命令面板,选择Python: Select Interpreter,选择已安装的Python版本。

===============================
VS code,通过 Ctrl+Shift+P 打开命令面板,选择Python: Select Interpreter,选择已安装的Python版本 3.12.1,
但是,在终端窗查看Python的版本为 3.6.8
python --version却输出 3.6.8
Python: Select Interpreter只控制编辑器提示、Lint、调试器使用 3.12.1;它不会自动修改普通终端 shell 的系统 PATH。VSCode 集成终端是独立 shell 进程,会读取操作系统环境变量;你的系统 PATH 中 Python3.6.8 路径优先级更高,直接敲
python命令就找到 3.6.8。
验证小命令,在终端执行:
# Windows
where python
python -c "import sys;print(sys.executable,sys.version)"
sys.executable:VSCode 选中解释器真实路径;where python:系统 PATH 搜索出来的 python 优先级列表,第一条就是 3.6.8。=================================
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。