2024 年更新:
最新的vscode 默认是支持自动切换环境了。就是前面没有(base) 表示环境也是切换好的,微软会弹窗告知你这点
- ctrl+shift+p打开palette面板
- 输入 select interpreter选择你想要的环境
- 左下角就能看到当前环境的信息
{
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"JavaScript Debug Terminal": null,
// "JavaScript Debug Terminal": {
// "extensionIdentifier": "ms-vscode.js-debug",
// "icon": "debug",
// "id": "extension.js-debug.debugTerminal",
// "title": "JavaScript Debug Terminal"
// }
"conda powershell terminal":{
"source": "PowerShell",
"args":"-ExecutionPolicy ByPass -NoExit -Command & 'D:\\ProgramData\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate 'D:\\ProgramData\\Miniconda3' ",
"title":"conda powershell terminal",
}
},
"terminal.integrated.defaultProfile.windows": "conda powershell terminal",
"python.terminal.activateEnvironment": true,
"python.pythonPath": "D:\\project\\cryptocurrency\\.env\\python.exe",
// 设置测试框架
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
// 设置日志格式
// "python.testing.pytestArgs": ["--log-format='%(asctime)s %(levelname)s %(message)s' ","--log-date-format='%Y-%m-%d %H:%M:%S'"],
"python.testing.pytestArgs": [
"."
]
}
2022 已过期
- ctrl+shift+p打开palette面板
- 搜索open user setting(JSON)
- 打开setting文件,添加下面代码
{
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows":[ "-ExecutionPolicy" ,"ByPass", "-NoExit", "-Command","& 'C:\\ProgramData\\Anaconda3\\shell\\condabin\\conda-hook.ps1'; conda activate 'C:\\ProgramData\\Anaconda3' "]
}
详细参数请参考安装环境下的快捷键文件。