Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

何があったのか

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

tiked_st
大学生.
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away