Posted in Python, Visual Studio Code

How to solve the input() error in Visual Studio Code when you run the code in the integrated terminal

This article was born some years ago but until lately I found the serious mistake in it. Now I fix it and I’m sure you can make it after you follow the steps. Sorry for those who searched this passage but left with depression.

First of all, you need to run the python code correctly in your Visual Studio Code, just having an annoying problem that you cannot deal with the input() error.

How do you know that? You can install an extension from VS Code Store named code runner(by Jun Han), and you will get a new right-click menu named Run Code in VS Code so that you can run the code in the integrated terminal of VS Code.

If you cannot run the python code in Visual Studio Code totally, this article may be not useful to help you with. You should check your environment, such as reinstall Python or VS Code.

Code runner is a very nice debug tool but it is read-only in the terminal so that you cannot deal with input().

To solve the problem is very easy:

  1. Install an extension named Python(by Microsoft) and you will get a new right-click menu in your editor.
  2. Keep on the editor’s UI and just save the .py file into your disk.
  3. Right click the editor’s UI and click the menu Run Python File in Terminal.
  4. Now you can get the Terminal on the bottom of the Visual Studio Code and you can input anything you want.
  5. Enjoy it!

Well, this solution is made for debugging in the integrated terminal. If you would like to save the file and run it in CMD or Powershell, that’s fine.