image.png
一般都配置三个json文件,但是好像没有配置的时候也能够编译和调试,不知道是不是原来装了什么插件,不过不重要。
launch.json配置:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "D:\\Anaconda3\\envs\\python36\\python",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
// "envFile": "${workspaceFolder}/.env",
"console": "integratedTerminal",
}
]
}
task.json文件
{
"version": "2.0.0",
"tasks": [
{
"label": "python3",
"type": "shell",
"command": "D:\\Anaconda3\\envs\\python36",
"args": ["${file}"]
}
]
}
setting.json文件会自动生成;
最关键的部分:
进入:File—>preference—>setting—>
image.png
在标注的地方输入对应的python路径,不过注意一个问题,在pycharm使用anaconda作为编译器的时候,自己用的是python.exe;但是vscode中的是python,而不是python.exe;不知道pycharm是不是也可以这样子。