Install Visual Studio Code for Python development

Published on June 22, 2022

Visual Studio Code for Python development

If you are a beginner to Python development, there are many editors and IDEs. If you are a school student, I would recommend that you download and install PyCharm Edu edition. It is free and has support for Python out of the box. You can get started working on Python within a few minutes using PyCharm Edu. I teach Python to my ACSL students and PyCharm Edu is my recommended IDE for beginners. Once you get the hang of Python, you can switch to more improved editors such as VS Code.

If you want a professional editor or IDE for Python development, Visual Studio Code (VS Code) is the best, in my opinion. At work, I use both Sublime Text (commercial edition) and Visual Studio Code. Note that VS Code is not unique to Python development, unlike PyCharm. However, there are several Python extensions that make VS Code very powerful for Python developers.

Download and install Visual Studio Code

  • Go to the VS Code download page at https://code.visualstudio.com/Download
  • Click and download the correct installation file.
  • Install VS Code by double-clicking on the installation file.
  • After installing VS Code, install the Python extension.

Install the Python extension from VS Code

  • Start VS Code.
  • Click on the Extensions icon in the left panel. It looks like this:

    VS Code extensions

  • It opens the EXTENSIONS: MARKETPLACE search box. Search for python and press ENTER.

  • The first result should be the Python extension by IntelliSense (Pylance).
  • Click on it and let it install.

    VS Code extensions search box

  • The Python extension is now installed.

Create a hello world program

  • Open the VS Code editor.
  • Go to File > New File. A new file gets created.
  • Enter this Python Hello World program.
print('Hello world!', 1 + 4)
  • Save it with File > Save. Give it a name ending in .py, like helloworld.py.
  • You will see it on the left panel. Run it with Run > Run Without Debugging.
  • The program opens a TERMINAL tab in the bottom panel and runs it.

    hello world

  • You can manage your Python programs; all will be shown in the left panel.

Shortcut on running Python programs

Instead of navigating to Run > Run Without Debugging each time, you can set a shortcut to run your Python programs. I use CTRL+B to run the current Python program.

To set up your shortcut to use CTRL+B, this is what you would do:

  • Click on the gear icon (Manage) and select Keyboard Shortcuts.

    Manage Keyboard Shortcuts

  • Under Keyboard Shortcuts, type python run.

    Keyboard Shortcuts Ctrl B

  • You will see Python: Run Python File in Terminal. Beside it, you will see the key binding, that is the shortcut. Change it to CTRL+B.

  • Go back to the program and press CTRL+B. The program will run in the terminal at the bottom.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Published on June 22, 2022