Code Runner Vscode Python3

Write and run Python code using our online compiler (interpreter). You can use Python Shell like IDLE, and take inputs from the user in our Python compiler.

In this post we'll look at how to develop in Python using Visual Studio Code. I'll also show you a few extensions that can make your life much easier while working with Python!

Initial setup

  • To run a python file you can right click in the editor and select Run Python File in Terminal. Bonus: If you want to run your python code with the code runner extension, in your workspace.
  • Python is an interpreted language, and in order to run Python code and get Python IntelliSense, you must tell VS Code which interpreter to use. From within VS Code, select a Python 3 interpreter by opening the Command Palette ( ⇧⌘P (Windows, Linux Ctrl+Shift+P ) ), start typing the Python: Select Interpreter command to search, then select.
  • Visual Studio Code is highly extensible and customizable. Take a look at some of the extensions that make Python development in VSCode a better experience. Python by Microsoft.
Run

When you install Python (which I recommend you do via the official installer), remember in which folder it was installed. And on Windows, make sure to tick the 'Add Python to PATH' in the first screen of the official installer.

Download Visual Studio Code and install it like you would any other application.

Open Visual Studio Code and navigate to the Extensions panel on the left hand side. There, look for the Python extension and install it

Once that's installed, you can open any folder using Visual Studio Code and create a file that ends in .py. The Python extension will use appropriate syntax highlighting and also help you code by offering you suggestions and hints.

You can change which version of Python the extension uses by clicking on the bottom left, where in the screenshot it says 'Python 3.7.4 32-bit'. This will let you select a different version from those you have already installed. Note that if you only have one version, you'll only be able to select that.

Here's a link to the Python extension: https://marketplace.visualstudio.com/items?itemName=ms-python.python

The Code Runner extension

Code Runner Vscode Python3

Another extension, aptly called 'Code Runner', allows you to run your code more easily than normal. It gives VSCode a 'Play' icon at the top right, and when you click it, the selected code will run.

This is great because it allows you to either:

  • Select a portion of your code and run it, for example if you want to double-check what it does;
  • De-select all your code and just open a file, and press the 'Play' icon to run the entire file.

Do note that if you select only a portion of the code and run it, this portion cannot depend on variables or functions defined elsewhere in the code.

Link: https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

The indent-rainbow extension

An extension called 'indent-rainbow' will color every indentation level in Python in a slightly different color, so you can very easily tell which parts of your code are at which indentation level.

This is what the extension will do:

Link: https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow

The Rainbow Brackets extension

If you like the indent-rainbow extension, you might also like Rainbow Brackets extension, which highlights nested parentheses, square brackets, and curly braces in different colours, making it easier to keep track of nested brackets.

Link: https://marketplace.visualstudio.com/items?itemName=2gua.rainbow-brackets#overview

The vscode-icons extension

While this extension is by no means required to run Python code, I use it and like it very much as it allows me to more easily scan my open files and folders by giving them nicer icons.

You can install this in order to change the icons displayed beside files and folders in your currently open project.

Link: https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons

Conclusion

Code Runner Vscode Python 3 Download

That's it! As long as your Python version is in your PATH (which happens automatically on Mac and Linux, and you must tick the box in the installer in Windows), the Python extension will straight work out of the box!

If you have persistent issues, Google is your best friend as tens of thousands of people use this extension, and almost all potential problems have already been discussed and solved in other occasions. The development team is also very helpful in their GitHub page.

The GitHub page also contains extensive guides and information on how to get the extension up and running, it case it's necessary!

Hope this has been helpful and your environment is now all set up. Happy coding!

Introduction

Are you tired of reinstalling extensions on each of your computer(s)? How about when you have to reset computer entirely? Or, how about you're an instructor, a hobbyist, or just 'getting your feet wet' in the fine craft of Python programming who does not know which extension(s) to select to get the job done both efficiently and effectively. Regardless, please do not waste time and energy on something so tedious as a process of installing extensions. Extensions are, in a word, awesome! Their premise is to extend the features and functionality of Visual Studio Code.

What extensions will I get by selecting this extension pack?

Glad, that you've asked! Please find the supervening extensions. Of course, I always love to hear your suggestions to improve this extension package. To do so, please create a new issue in the Issues Section. After all, the ultimate goal for this extension pack is convenience at the click of one button.

Recommended Theme for Python Development

  • Chromodynamics Theme: A VSCode plugin extends Python programming in VSCode through a highly recommended (at least, from yours truly!)dark color scheme from MagicStack. Note: This works well with MagicPython, which is included below. :-)

Recommended Extensions for Python Development

Python3
  • AREPL for Python: A Visual Studio Code extension that automatically analyzes Python code in real-time as you code.

  • Better Comments: A Visual Studio Code extension whose premise is to categorize your comments (annotations) in your Python code, through:

    • Alerts

    • Queries

    • TODOs

    • Highlights

    • Commented out code can also be styled to make it clear the code shouldn't be there

    • Any other comment styles you'd like can be specified in the settings

  • Bracket Pair Colorizer 2: A Visual Studio Code extension that allows matching brackets to be identified with colors. Note: The user can define which tokens to match, and which colors to use.

  • Code Runner: A Visual Studio Code extension that allows for either code snippets or code files to be run in multiple programming languages, such as Python.

  • Code Spell Checker: A Visual Studio Code extension that serves as a basic spell checker that works well with camelCase code, thereby catching common spelling errors whilst keeping the number of false positives low.

  • Django: A VSCode plugin that provides 'beautiful' syntax and scoped snippets.

  • EditorConfig for VS Code: A Visual Studio Code extension that attempts to override user/workspace settings with settings found in .editorconfig files. Note: No additional or vscode-specific files are required. Conversely, if root=true is not specified, EditorConfig will continue to look for an .editorconfig file outside of the project.

  • GitLens — Git supercharged: A Visual Studio Code extension 'supercharges the Git capabilities' out-of-the-box. Note: GitLens 'helps you to visualize code authorship at a glance via Git blame annotations and code lens, seamlessly navigate and explore Git repositories, gain valuable insights via powerful comparison commands.'

  • Guides: A Visual Studio Code extension that 'add various indentation guide lines.'

  • Jinja: A VSCode plugin that supports Jinja template language support, including language colorization support, including but not limited to type annotations, f-strings, and regular expressions.

  • Kite Autocomplete for Python and JavaScript: A Visual Studio Code extension that offers 'AI powered autocomplete, code snippets, code signatures, and cursor-following documentation.'

  • Live Share Extension Pack: An official VSCode extension pack that enable real-time collaborative development, including integrated audio and text chat, which supports various use cases.

  • MagicPython: A VSCode plugin that supports preferences and syntax highlighter for 'cutting edge' Python 3, whereby serving as a drop-in replacement for the default Python package.

  • Markdown All in One: A Visual Studio Code extension that offers an all-in-one solution for utilizing Markdown, as the name suggests. :)

  • markdownlint: A Visual Studio Code extension whose premise is to serve as Markdown linting and style checking.

  • Markdown TOC: A Visual Studio Code extension that generates Table of Contents for headlines from parsed markdown file.

  • Prettier - Code Formatter: A Visual Studio Code extension that 'enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.'

  • PyDev: A Visual Studio Code extension that provides an integration of PyDev, enabling users to leverage the features of one of the leading Python IDEs out-of-the-box. Note: Please be advised that this extension provides a 30-day trial after installation, whereby afterwards it must be purchased for continued use.

  • PyRight: A Visual Studio Code extension serving as a fast type checker meant for large Python source bases, whilst run in a 'watch' mode and performs fast incremental updates when files are modified.

  • Python: An official Microsoft VSCode plugin that provides support for the Python programming language albeit for all actively supported versions: 2.7, >=3.6, including Functionalities, such as:

    • Code Formatting

    • Code Navigation

    • Debugging

    • IntelliSense

    • Jupyter Notebook Support

    • Linting

    • Refactoring

    • Snippets

    • Test Explorer

    • Variable Explorer

    • Note: Please be advised that you will need a Python distribution. Depending on what you utilize Python programming for, I can recommend without hesitation either the official Python Distribution or Anaconda. Anaconda graphical user interace is best for data science, artificial intelligence, and machine learning. Conversely, the official Python distribution is best for application development (desktop, web, or GIS). I have included the weblinks to the respective homepages, since usually pages are moved and the direct weblink would be dead. :-(

  • Python Docstring Generator: A Visual Studio Code extension that automatically generates detailed Docstrings for Python functions.

  • Python Test Explorer for VSCode: A VSCode plugin which allows you to run your PythonUnitest tests and Pytest in the sidebar, with the assistance of yet another plugin Test Explorer UI. ;-)

  • Run on Save: A Visual Studio Code extension that configures commands that get run whenever a file is saved. Note: Commands only get run when saving an existing file. Creating new files and Save as does not trigger the commands.

  • Sync Settings: A Visual Studio Code extension that synchronize settings, snippets, themes, file icons, launch, keybindings, workspaces and extensions across multiple computers using GitHub Gist.

  • TabNine: A Visual Studio Code extension that indexes your entire project by reading your .gitignore or other files, and determines which files to index.

  • Test Explorer Live Share: A VS Code plugin that serves as the 'glue' between the previously mentioned Test Explorer UI and Live Share Extension Pack, respectively.

  • Test Explorer UI: A VSCode plugin provides an extensible user interface for running tests. Note: This plugin works with a corresponding Test Adapter plugin, which for this extension pack is: Python Test Explorer for VSCode. Moreover, this plugin can be used in Live Sharesessions by installing the Test Explorer Live Share plugin. No worries, this Extension Pack got you've covered. :)

  • Visual Studio IntelliCode: A VSCode plugin that provides AI-assisted development features for Python, with insights based on understanding your code context combined with machine learning.

  • WakaTime: A Visual Studio Code extension that automatically derives metrics, insights, and time tracking generated from your programming activity.

  • YAML: A Visual Studio Code extension that provides comprehensive YAML Language support, via the yaml-language-server, with built-in Kubernetes syntax support.

Please feel free to disable any plugin that you do not wish to have activated from the use of our extension pack. :)

Visual Studio Code Tips and Tricks from its Docs

Runner
  • Please puruse the Visual Studio Code Variables Reference, if you wish to use variables substitution.

  • VSCode Keyword Shortcuts

    • Linux: Link contains PDF.

    • macOS: Link contains PDF.

    • Windows: Link contains PDF.

  • Please puruse the Visual Studio Code Keybindings, if you wish to use custom keybindings.

    • Optional Keymap Extensions: I recommend the specific keybinding extension that meets your use case through Microsoft, if possible.
  • Please puruse the Visual Studio Code Tips and Tricks to make your experience a little bit more enjoyable.

Note

It is my pledge to update this Extension Package with update extension as needed to perform the job efficiently and effectively. Likewise, the Extensions list will be categorized accordingly and more detailed information regarding plugins will be incorporated in the near future. I will certainly be on the lookup for some helpful Python Development hints and tips to make your experience enjoyable. Cheers! :)

Recommended Tutorials for Visual Studio Code

  • Visual Studio Code Crash Course (1:32:34): Courtesy of Mr. James Quick from FreeCodeCamp.org, whom provided a VS Code Cheatsheet on his website (note: free registration required).

  • Setting Up VSCode for Python Programming (22:19): Courtesy of the one and only Mr. Brad Traversy from Traversy Media.

Recommended Tutorials on Python

From Traversy Media

  • Python Crash Course for Beginners (1:35:36) [November 28, 2018]

  • Pipenv Crash Course (15:39) [December 23, 2018]

  • Python and MySQL Crash Course (24:38) [June 15, 2020]

  • Object Oriented Programming (OOP) in Python (43:46) [August 21, 2020]

  • Python Django Crash Course (1:11:50) [September 4, 2019]

From FreeCodeCamp.org

  • Learn Python - Full Course for Beginners (4:26:51) [July 11, 2018]

  • Intermediate Python Programming Course (5:55:46) [August 27, 2020]

Please let me know if you know any other FREE Python resources that might benefit others by creating a new issue in the Issues Section.

Attributions

Thank you for all the developers that built these above referenced extensions. My genuine appreciation for your hard work and dedication to the developer community. :)

Visual Studio Code Extension Packs

  • COBOL Essentials: A Visual Studio Code extension for Mainframe development, particularly Mainframe as a Service (MaaS). Link contains PDF from Washington Technology Services, which provides an example of MaaS.

  • Java Essentials: A Visual Studio Code extension pack for Java development.

  • .NET Core Essentials: A Visual Studio Code extension pack for .NET Core development, with special provisions for Azure Cloud development through official Microsoft extensions.

  • PHP Development Essentials: A Visual Studio Code extension pack that serves as the comprehensive version of Web Development Essentials pack, which, unlike Web Development Essentials, does not have Angular or React extensions.

  • Python Essentials: This Visual Studio Code Extension Pack is what you are currently seeing. :)

  • Web Development Essentials: A Visual Studio Code extension pack that serves as the condensed version of the PHP Development Essentials pack for Visual Studio Code, whose main premise is centered around JavaScript ecosystem.

Disclaimer

Please be advised that this is an 'off-the-clock' passion project, whose intent is to be utilized by anyone (including my colleagues) who will derive benefit from this one-click installation of popular extensions that I felt was a relevant theme to this Extension Pack.

Code Runner Extension

Signing Off

Vscode

Vs Code Run Button

Please enjoy! Cheers!