How to setup Code Runner in Visual Studio Code for Python



Hello all,

(this is my first question here :blush:)
I am learning Python and have decided to use Visual Studio Code as my IDE.
I have installed Visual Studio Code 1.23.1 and added extensions - Python, Code Runner.

With Code Runner, now I can see the Run Code symbol (triangle) and on highlighting it, I see the shortcut Ctrl + Alt + N. But when I try to use it to run the code that asks for user input, I can’t find a way to provide the input. When I try to enter user input, I get error message “Cannot edit in read-only editor”. I think this is because I am missing some configuration part for Code Runner like setting up PATH or some other Workspace settings.

Question: Please assist me in identifying what all configuration will I need to do and how?

I did select “Add Python 3.6 to PATH” while installing Python. I have attached screenshots for reference:

Note: Even now when I right click and select “Run Python File in Terminal” for the same program, I can enter user input fine and get the expected output.

Thank you in advance!


In your vs_code folder you should have a settings.json file. In it, set your python path. This is handy if you like to use virtual environments. here’s what mine looks like:

    "python.pythonPath": "/Users/cathleenturner/.local/share/virtualenvs/services-3KSPTmbN/bin/python",
    "python.linting.pylintEnabled": true,
    "python.linting.pep8Enabled": false,
    "python.pydev.pythonPath": ["/Users/cathleenturner/code/rio/test/services",
     "files.autoSave": "afterDelay",
    "python.linting.flake8Enabled": true,
    "python.linting.enabled": true,
    "python.linting.pylintArgs": [],
    "python.venvPath": "/Users/cathleenturner/.local/share/virtualenvs"