三歩あるけば物も忘れる

お腹のお肉がメタボックル

ユーザ用ツール

サイト用ツール


DevelopmentLanguage:BuDevEnv:VisualStudioCodeSetting

20.VisualStudioCode設定

Python拡張機能のインストール


①サイドバーの[Extensions]を選択する。
②検索欄で「Python」を検索する。
③Microsoftが出しているPythonの拡張機能をインストールする。

Python拡張機能、ターミナル設定


①サイドバーの[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」+「`」を入力します。
②以下の通り、指定した環境変数でターミナルが開けば成功です。

コメント

コメントを入力:
D A Q V B
 
DevelopmentLanguage/BuDevEnv/VisualStudioCodeSetting.txt · 最終更新: 2023/01/04 by admin