How to Install VSCode for Python on Ubuntu

How to Install VSCode for Python on Ubuntu

In this Python tutorial, we will discuss how to install and prepare Visual Studio Code or VSCode for Python development on the popular Linux distribution i.e. Ubuntu. It provides several features for Python development including IntelliSense, Syntax Highlighting, Bracket Matching, Snippets, Linting, etc. This tutorial provides all the steps required to install VSCode on Ubuntu 18.04 LTS, though the steps should be similar for other Linux systems.

Visual Studio Code or VSCode is a cross-platform, lightweight editor and became popular in a very short span. It provides support for several programming languages. It also supports plugin development and there are several community-driven plugins available for it.

In this tutorial, we will discuss how to install and prepare Visual Studio Code or VSCode for Python development on the popular Linux distribution i.e. Ubuntu. It provides several features for Python development including IntelliSense, Syntax Highlighting, Bracket Matching, Snippets, Linting, etc. This tutorial provides all the steps required to install VSCode on Ubuntu 18.04 LTS, though the steps should be similar for other Linux systems.

It assumes that Python is already installed on the system. You may also be interested in How To Install Python 3.8 On Ubuntu 18.04.

You might also be interested in Python Cheatsheet to learn or brush up the basics of Python.

Step 1 - Download Visual Studio Code

We can download Visual Studio from the official download page. It provides options for Ubuntu as shown in Fig 1.

VSCode Download Fig 1

Click on the .deb Download Button to start the download. You can also download the gz file to install it directly without using the deb package. This tutorial provides steps to install VSCode using the Debian package.

Step 2 - Install Visual Studio Code

In this step, we will install the Visual Studio Code downloaded by us in the previous step. Double click the installer to execute it. It will show the installer screen as shown in Fig 2.

VSCode Install Fig 2

Click on the Install Button to start installing VSCode. It will show installation progress as shown in Fig 3.

VSCode Install Progress Fig 3

After the successful installation, it will show the final screen as shown in Fig 4.

VSCode Install Finish Fig 4

Now close the screen to complete the installation. Click on the Show Applications icon at the bottom right corner of Ubuntu 18.04. It should show Visual Studio Code as shown in Fig 5.

VSCode Application Fig 5

You may add it to your Favorite Apps or create a desktop shortcut icon based on your preferences. Launch VSCode to start coding in Python. It will show the welcome screen as shown in Fig 6.

VSCode Welcome Fig 6

Step 3 - Marketplace

You can see all the available plugins on the Marketplace dedicated to the Visual Studio Code. Type python in the search box and click on the Search Button. The results should be similar to one as shown in Fig 7.

Visual Studio Code - Python Marketplace Fig 7

We can also browse the available extensions within the IDE by clicking on View -> Extensions or press Ctrl + Shift + x. Enter python on the Search Box and hit Enter Key. It will show the same extensions list within the IDE as we saw on the Marketplace Page as shown in Fig 8.

VSCode Python Extensions Fig 8

Step 4 - Install Extensions

We will install the most important extensions as part of this tutorial. Also, make sure that you are using the most recent version of Python. Your system should have at least Python 3 to use the new features available in Python.

Python and MagicPython are the most important extensions that every Python developer must install for Visual Studio Code or VSCode. The other extensions can be installed based on the requirements. Install both the extensions as shown in Fig 9 and Fig 10.

Notes: We can also install the recommended Python Extension Pack including Python, MagicPython, Jinja, and Django**.**

VSCode Python Extension Main Fig 9

VSCode Python Extension Magic Fig 10

Also, install the extension Code Runner to execute the program.

Code Runner Fig - Code Runner

Step 5 - Getting Started with Python - Hello World

In this section, we will create the Hello World i.e. HelloPython project and write and execute the first program using VSCode to start programming with Python development.

Click on File -> Open Folder or press Cntrl + K and Cntrl + O to open the File Chooser to select the project folder. It will open the selected folder as highlighted in Fig 11.

VSCode Python Folder Fig 11

Now click on the New File Icon as highlighted in Fig 12.

VSCode Python Add File Fig 12

Enter the file name as hello.py and hit the Enter Key. It will create the Python file as shown in Fig 13.

Notes: It will also ask to install Python Linter extension in case it's not installed. It's a must-have extension for Python.

VSCode Python View File Fig 13

Update the file and write the first program to print Hello Python as shown in Fig 14.

VSCode Python Update File Fig 14

Now right-click the file and choose the option Run Code. It will open the terminal within the editor, and execute the code as shown in Fig 15 and Fig 16.

VSCode Python Run File Fig 15

VSCode Python File Output Fig 16

This is how we can install the Visual Studio Code for Python development. We have also written our first hello world program and executed it within the editor using the Code Runner extension.

python ubuntu vscode

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

Python Hello World Program - Create & Run Your First Python Program in PyCharm

Python Hello World Program - Your first step towards Python world. Learn how to create the Hello World Python program in PyCharm.

2 Ways to Upgrade Ubuntu 18.04/18.10 To Ubuntu 19.04 (GUI & Terminal)

This tutorial is going to you 2 ways to upgrade Ubuntu 18.04 and Ubuntu 18.10 to 19.04. The first method uses the graphical update manger and the second method uses command line. Usually you use the graphical update manager to upgrade Ubuntu desktop and use command line to upgrade Ubuntu server, but the command-line method works for desktops too.

Setting up a Python Development Environment in VSCode on Windows

In this Python Programming Tutorial, we will be learning how to set up a Python development environment in VSCode on Windows. VSCode is a very nice free editor for writing Python applications and many developers are now switching over to this editor. Learn how to install VSCode, get the Python extension installed, how to change Python interpreters, create virtual environments, format/lint our code, how to use Git within VSCode, how to debug our programs, how unit testing works, and more.

Setting up a Python Development Environment in VSCode on Mac

In this Python Programming Tutorial, we will be learning how to set up a Python development environment in VSCode on MacOS. VSCode is a very nice free editor for writing Python applications and many developers are now switching over to this editor. Learn how to install VSCode, get the Python extension installed, how to change Python interpreters, create virtual environments, format/lint our code, how to use Git within VSCode, how to debug our programs, how unit testing works, and more.