Toggle Sidebar   Previous Lecture Complete and Continue  

  Install Visual Studio Code and the Python Extension

In this tutorial, I will show how to install visual studio code on mac. Visual Studio Code is free and available on your favorite platform – Linux, Mac OSX, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.

Install visual studio code mac.

Four easy steps can do the job for you.

  1. Download Visual Studio Code for Mac.
  2. Double-click on the downloaded archive to expand its contents.
  3. Drag Visual Studio Code.app to the Applications folder, making it available in the Launchpad.
  4. Add VSCode to your Dock by right-clicking on the icon and choosing Options Keep in Doc.

After installing the VS Code, we can also configure the code to open from a command line, and it is pretty darn easy for us to do that.

  1. Launch Visual Studio Code.
  2. Open the Command Palette (⇧⌘P) and type ‘shell command‘ to find the Shell Command: Install ‘code’ command in the PATH command.

Now, if you have created any project that goes into that folder and hit the following command to open that project into the Visual Studio Code.

code .

VS Code Extension Marketplace.

The features that Visual Studio Code includes out-of-the-box are just the start. VS Code extensions let you add languages, debuggers, and tools to your installation to support your development workflow.

By default, VS Code works just like a simple text editor and has no built-in support for python. What We mean by the previous statement is even though you can write python code in VS Code now, you won’t be able to leverage some of the developer tools or techniques that make writing code a lot easier. For example, let us start creating a python file with the name “main.py”, import the JSON module and print the statement “Hello World”. As you write the code, you can see that there is no auto-complete or no IntelliSense provided by the code editor and you need to write the entire statement on your own.

To avoid that, we need to install the Python extension for Visual Studio Code by navigating to https://marketplace.visualstudio.com/items?itemName=ms-python.python and download the extension:


Alternatively, you can also hit the Extensions icon in the left-hand pane inside Visual Studio Code and search for the keyword “python”. Select the extension which is provided by Microsoft and click on Install. I have already installed the extension on my machine:


As soon as the Python extension has been installed, you can see that a “Run” button on the extreme right-hand top appears using which you can run the python file directly within the integrated terminal in VS Code. Also, another thing that you can notice here is that you get several options as to how would you like to run the open python file:

Another point that you might notice after installing this extension is that it provides us with some sort of handy documentation when we hover the cursor over a specific object. For example, in the same file, if we hover over the keyword “Path”, you can now see that a small tooltip is visible, which contains information about the Path module.

Path IntelliSense in Visual Studio Code for Python

Path IntelliSense allows you can easily get the autocomplete keywords from a drop-down. For example, if you now start typing “import”, the editor will automatically start suggesting keywords that match the word as you are typing. This helps to achieve a faster speed in writing code as you need not manually type the entire words to make the script work:

Conclusion

In this lecture, we have explained how to download and install Visual Studio Code on your local machine and how to install an extension inside VS Code. We have also explained how to set up the Visual Studio Code for Python programming by installing the necessary extensions, which offers the developers with much more flexibility and helps in writing code faster in a more productive way.

In the next section, we will start to initialize our project. See you there!