~~NOCACHE~~ ~~DISCUSSION~~ ## 20.VisualStudioCode設定 #### Python拡張機能のインストール {{:DevelopmentLanguage:BuDevEnv:pasted:20230104-122308.png?direct 400x0}} ①サイドバーの[Extensions]を選択する。 ②検索欄で「Python」を検索する。 ③Microsoftが出しているPythonの拡張機能をインストールする。 #### Python拡張機能、ターミナル設定 {{:DevelopmentLanguage:BuDevEnv:pasted:20230104-140815.png?direct 0x400}} {{:DevelopmentLanguage:BuDevEnv:pasted:20230104-150703.png?direct 0x400}} ①サイドバーの[Manage]から[Settings]を選択します。 ②右上の「設定(UI)を開く」をクリックします。 ③setting.jsonが開くので、以下の設定項目を編集します。 ・python.condaPath:"[Anacondaインストールパス]\\anaconda3\\envs\\[環境名]" ・terminal.integrated.profiles.windows:"args"に「"/K", "[Anacondaインストールパス]\\anaconda3\\Scripts\\activate.bat", "[Anacondaインストールパス]\\anaconda3\\envs\\[環境名]"」 ・terminal.integrated.defaultProfile.windows:"Command Prompt" ・python.defaultInterpreterPath: "[Anacondaインストールパス]\\anaconda3\\envs\\[環境名]\\python.exe" ・python.terminal.activateEnvironment: false ・code-runner.runInTerminal: true 上記設定をすると、以下のイメージになるかと思います。 "python.condaPath": "C:\\Users\\admin\\anaconda3\\envs\\py39", "terminal.integrated.profiles.windows":{ "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" }, "Command Prompt": { "path": [ "${env:windir}\\Sysnative\\cmd.exe", "${env:windir}\\System32\\cmd.exe" ], "args": [ "/K ", "C:\\Users\\admin\\anaconda3\\Scripts\\activate.bat", "C:\\Users\\admin\\anaconda3\\envs\\py39" ], "icon": "terminal-cmd" }, "Git Bash": { "source": "Git Bash" } }, "terminal.integrated.defaultProfile.windows": "Command Prompt", "python.defaultInterpreterPath": "C:\\Users\\admin\\anaconda3\\envs\\py39\\python.exe", "python.terminal.activateEnvironment": false, "code-runner.runInTerminal": true #### 動作確認 ①「ctrl」+「shift」+「`」を入力します。 ②以下の通り、指定した環境変数でターミナルが開けば成功です。 {{:DevelopmentLanguage:BuDevEnv:pasted:20230104-141950.png?800x0 nolink}} {{tag>VisualStudioCode Anaconda}}