我有个 hello.py 文件,我要直接运行这个文件,但是引用的 python 是系统自带的,不是我虚拟环境中的。网上资料说需要设置 tasks.json,贴下我 tasks.json 的配置,
{
"version": "0.1.0",
"command": "/Users/apple/github/flasky-blog/venv/bin/python",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}
我已经把 command 的值也就是 python 路径给写死了,但是直接 run hello.py 还是用的是系统的 python。
不过最让我困惑的是,我已经在 setting.json 中指定了"python.pythonPath": "${workspaceRoot}/venv/bin/python3",而且 debug 是没有问题,再贴下我的 debug.json 配置,
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
}
唯独这个 tasks.json,按道理说我已经指定路径了,可是我一 run 就读到系统的 python 路径了。
给帮忙看看。谢谢