LoginSignup
5
5

More than 3 years have passed since last update.

VScodeの拡張機能,Code RunnerでPythonの2系と3系を切り替える方法(pathの設定)

Last updated at Posted at 2019-06-06

何があったのか

VScodeの拡張機能であるCode RunnerでPythonを実行したら,2系で実行された.

3系に切り替えたい.

方法

VScodeの拡張機能から,Code Runnerをクリック.表示された詳細の部分に思いっきり書いてある.以下引用

Configuration
Make sure the executor PATH of each language is set in the environment variable. You could also add entry into code-runner.executorMap to set the executor PATH. e.g. To set the executor PATH for ruby, php and html:

setting.json
{
    "code-runner.executorMap": {
        "javascript": "node",
        "php": "C:\\php\\php.exe",
        "python": "python",
        "perl": "perl",
        "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
        "go": "go run",
        "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    }
}

というわけで,表示 -> コマンドパレット -> 基本設定:設定(json)を開く

よりsetting.jsonを開く.setting.jsonに以下を記入

setting.json
{   //ここの{}は元からある
    "code-runner.executorMap": {
        "python": "python3系のpath\\Python37\\python.exe",
    }
}

無事,3系で実行できました.

最後に

Code Runner 便利

coderunner.jpg

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5