vscode配置python擴充套件外掛,以及雙環境配置
阿新 • • 發佈:2019-02-03
1、外掛列表
2、setting.json檔案配置
使用者設定
{
"window.zoomLevel": 0,
"[python]": {},
"workbench.colorTheme": "One Dark Pro",
// By default, create file username
"fileheader.Author": "dabangba",
// By default, update file username.
"fileheader.LastModifiedBy": "dawangba",
"fileheader.tpl" : "/*\r\n * @Author: {author} \r\n * @Date: {createTime} \r\n * @Last Modified by: {lastModifiedBy} \r\n * @Last Modified time: {updateTime} \r\n */\r\n",
"files.encoding": "utf8",
"vsicons.dontShowNewVersionMessage": true,
"python.jediEnabled": true,
"python.autoComplete.addBrackets" : true,
"workbench.iconTheme": "material-icon-theme",
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
},
"workbench.sideBar.location": "left",
}
有的時候vscode 會沒有了自動補全功能,這時候我們可以修改下面的值
"python.jediEnabled": true,
將該值設定true 開啟jedi 自動補全功能,不適用微軟的自動補全
工作區設定
{
"editor.fontFamily" : "Consolas, 'Courier New', monospace",
"python.linting.pylintEnabled": false,
"python.pythonPath": "D:\\anaconda2\\python.exe",
//"python.pythonPath": "D:\\anaconda3\\python.exe",
"files.encoding": "utf8",
"python.formatting.provider": "yapf",
}
3、task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Python2.7.15",
"type": "shell",
"command": "D:/anaconda2/python.exe",
//"command": "D:/anaconda3/python.exe",
"args": [
"${file}"
],
"presentation": {
"reveal": "always",
"panel": "shared"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
這裡面我使用了雙環境,也就是2.7和3.6的
我們可以安裝anaconda2,和anaconda3,這樣win10電腦就可以使用兩個環境了,
先裝anaconda3 然後最後把它新增到系統路徑當中,成為預設使用該版本
然後再安裝anaconda2,不需要把它新增預設系統路徑了
然後vscode中會自動識別出這兩個版本,我們可以在vscode中任意切換版本庫
點選Anaconda5.2.0
然後切換我們的版本庫
預設右鍵 運行當前python檔案可以使用python3的直譯器 執行該檔案,
使用ctrl+shift + B 可以使用python2的直譯器 執行