Why is Code Runner using the old 2.71 version of Python instead of 3.x on OSX?

I am trying to use the newer version of Python but when I type:

    import sys
    print sys.version_info

I get back:

    sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)

In the terminal when I enter python I get:

Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin

When I enter python3 I get:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

As you see, I have installed Python 3.3 but no matter what I do I can't seem to actually use it in CodeRunner.


Solution 1:

For the latest version of VS Code, you need to open settings (shift+command+p) and override the python interpreter value.

vscode settings

Solution 2:

In new versions of the settings.json file, just enter:

"code-runner.

(Note the ") and it should show an auto-complete list (or you can press ctrl+space) and select "code-runner.executorMap". It should show all of the run commands. Change:

"python": "python -u",

to

"python": "python3 -u",

To change your IntelliSense for error handling in python3, open the Command Palette (ctrl+shift+P) and select "Python: Select interpreter" and select python 3.x.x.

Solution 3:

CodeRunner->Preferences->Languages->Run Command

edit "python $filename" to "python3 $filename"