Python in Visual Studio Code (2024)

Visual Studio Code is a free source code editor that fully supports Python and useful features such as real-time collaboration. It's highly customizable to support your classroom the way you like to teach.

"Visual Studio Code is the best balance of authenticity and accessibility... Visual Studio Code doesn't feel 'fake', it's what real software developers use. Plus, Visual Studio Code works on every OS!" - Professor Zachary Dodds from Harvey Mudd College

Read below for recommendations for extensions, settings, and links to free lessons that you can use in your classes.

Intro to CS at Harvey Mudd College

Professor Zachary Dodds is a Computer Science professor at Harvey Mudd College who teaches several introductory classes both for students new to Computer Science and students from a non-Computer Science background. He co-created the popular introduction to Computer Science class CS5, which attracts students from all backgrounds to develop programming and problem-solving skills and to build "a coherent, intellectually compelling picture of Computer Science". The class is taught with Python and uses VS Code as the recommended editor.

Why Visual Studio Code?

Professor Dodds has been recommending and using Visual Studio Code in his classes since it debuted in 2015.

"Visual Studio Code is the best balance of authenticity and accessibility... Visual Studio Code doesn't feel 'fake', it's what real software developers use. Plus, Visual Studio Code works on every OS!"

VS Code runs on Windows, macOS, Linux, and even Chromebooks.

Classroom settings

Since VS Code is easy to customize, Professor Dodds is able to tailor the editor for his students, preferring to hide IntelliSense, or code completion suggestions, so they can learn from what they type and reinforce the conceptual models being built.

Here are the settings his students use:

"editor.quickSuggestions": false,"editor.acceptSuggestionOnCommitCharacter": false,"editor.suggest.filterGraceful": true,"editor.suggestOnTriggerCharacters": false,"editor.acceptSuggestionOnEnter": "on","editor.suggest.showIcons": false,"editor.suggest.maxVisibleSuggestions": 7,"editor.hover.enabled": false,"editor.hover.sticky": false,"editor.suggest.snippetsPreventQuickSuggestions": false,"editor.parameterHints.enabled": false,"editor.wordBasedSuggestions": "matchingDocuments","editor.tabCompletion": "on","extensions.ignoreRecommendations": true,"files.autoSave": "afterDelay",

You can find the most up-to-date settings on his course website: CS5 - Python Tips.

Integrated Terminal

Professor Dodds also utilizes the built-in terminal heavily in his class as an introduction to running programs from the command line and navigating around their machine all within Visual Studio Code. He appreciates how "the built-in terminal panel does not try to automate too much (which, if it did, would deprive newcomers of the experience of the information-flow that's going on)."

In the video below, the student does all of their command line and coding work in one place, such as installing Python libraries, while working on Lab 3 from the CS5 class:

Python in Visual Studio Code (1)

Thank you, Professor Dodds, for sharing your story! If you’re interested in using VS Code to teach Python in your classes, you can get started with the Python Education Extension Pack below!

Python Extension Pack

Unsure which extensions to recommend to your students? You can point your students to the Python Education Extension Pack that contains essential and helpful extensions for the classroom. You can download the extension pack from the VS Code Marketplace:

Python in Visual Studio Code (2)

The extension pack contains:

  • Python for basic Python functionality like compiling, debugging support, linting, Jupyter Notebooks, unit tests, and more.
  • Live Share to enable real-time collaboration.
  • Remote - SSH to work on remote projects (for example, to access lab machines) through SSH with full VS Code functionality.
  • Markdown+Math for full LaTeX support in Markdown.
  • Python Test Explorer for Visual Studio Code to visualize and run Python tests in the side bar.
  • Code Runner to run snippets (selected code) and single files of any code with a single click.

Free Python and Data Science lessons

NASA-inspired lessons

This learning path enables students to use Python to explore doing analyses and projects inspired from real-world problems faced by National Aeronautics and Space Administration (NASA) scientists. View full details of the lessons under NASA-inspired Lessons.

Python in Visual Studio Code (3)

Learn Python with Over The Moon

These space-themed lessons were inspired by the Netflix film, Over the Moon, and will introduce students to data science, machine learning, and artificial intelligence using Python and Azure. View full details on Learn Python with Over The Moon.

Python in Visual Studio Code (4)

Wonder Woman-inspired lessons

Give an introduction to Python with "Wonder Woman 1984"-inspired lessons that help students learn about the basics like conditionals and variables. Get full lesson details under Learn Python with Wonder Woman.

Python in Visual Studio Code (5)

Python in Notebooks

Learn the basics of Python. View the full lesson at Write basic Python in Notebooks in Visual Studio Code.

Python in Visual Studio Code (6)

Set up your Python beginner development environment

A step-by-step guide to installing and setting up your Python and VS Code environment. View the full lesson at Set up your Python beginner development environment with Visual Studio Code.

Python in Visual Studio Code (7)

Python in Visual Studio Code (2024)

FAQs

Can I use Python in Visual Studio Code? ›

Visual Studio Code is a free source code editor that fully supports Python and useful features such as real-time collaboration.

How to install Python in VS Code Terminal? ›

How to Install Python on VS Code
  1. Launch the VS Code application.
  2. Click on the “Extensions” tab.
  3. Type “python” on the search input located on the left side of the window.
  4. Select the Python extension you want to install.
  5. Click on the blue“Install” button to complete the Python installation.
Jul 14, 2023

Is PyCharm better than VS Code? ›

PyCharm excels with its Python-specific features, ideal for developers immersed in Python's ecosystem. Conversely, VSCode's appeal lies in its versatility, light footprint, and extensive extensions, suitable for multi-language projects.

How to run Python in terminal? ›

To execute a Python script, first open a terminal, then navigate to the directory where the script is located, and finally, run the script using the 'python' command followed by the script's name. On Linux, consider using python3 to ensure you're using Python 3.

How to put Python in Visual Studio? ›

Download and install the Python workload

If you have Visual Studio installed already, open Visual Studio and run the installer by selecting Tools > Get Tools and Features. The Community edition is for individual developers, classroom learning, academic research, and open source development.

How do I run a Python script? ›

To run a Python script in Terminal from the command line, navigate to the script's directory and use the python script_name.py command. Redirecting output involves using the > symbol followed by a file name to capture the script's output in a file. For example, python script_name.py > output.

How do I activate Python in VS Code? ›

Run
  1. Select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. ...
  2. From the Command Palette (Ctrl+Shift+P), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter.
Jan 17, 2024

Do I need to install Python on VS Code? ›

You must install a Python interpreter yourself separately from the extension. For a quick install, use Python from python.org and install the extension from the VS Code Marketplace.

How to open Python in Visual Studio? ›

Open the local code folder
  1. Launch Visual Studio. ...
  2. Browse to the folder that contains your Python code and choose Select Folder:
  3. Visual Studio displays the files in Solution Explorer in the Folder View. ...
  4. When you open a Python folder, Visual Studio creates several hidden folders to manage settings related to the program.
Apr 18, 2024

Should I use Visual Studio or VS Code for Python? ›

The primary reason why VS Code seems better in terms of usage in this debate of Visual Studio vs Visual Studio Code is that it offers incredible support, it can work across all platforms, and is lightweight and robust. It can do everything in just one place.

Do I need both Python and PyCharm? ›

To use Python directly on your computer you'll need to have both Python, the programming language, and a coding editor installed on your computer. The editor is the software you'll use to write and run the code from and we use an editor called PyCharm (Community Edition).

Which IDE is mostly used for Python? ›

PyCharm. In industries most professional developers use PyCharm and it has been considered the best IDE for python developers. It was developed by the Czech company JetBrains and it's a cross-platform IDE. It gives daily tips to improve your knowledge of how you can use it more efficiently which is a very good feature.

Why is Python not found in terminal? ›

To resolve the python: command not found error: Check if Python is installed (Install it if it's missing). Update where Python is located by adjusting the PATH. Make sure the correct Python version is used by adding or adjusting symbolic links.

Where to write Python code? ›

Several general editors and IDEs support Python development. These include Visual Studio Code, Eclipse with PyDev, Sublime Text, GNU Emacs, Vi/Vim, and Visual Studio with PTVS.

How to create a Python environment in VS Code? ›

  1. To create local environments in VS Code using virtual environments or Anaconda, you can follow these steps: open the Command Palette (Ctrl+Shift+P), search for the Python: Create Environment command, and select it.
  2. The Python extension tries to find and then select what it deems the best environment for the workspace.

Can you use Python without Visual Studio Code? ›

Yes you need to learn about Python Environments and many other things. I suggest you learn as much as you can using your local system. You can do that with simple Python programs and learn a lot. One possibility is to install Windows Subsystem for Linux (WSL) if you have not.

Where can I run Python code? ›

Running Python code online offers numerous benefits, including convenience, collaboration, and access to powerful computational resources. Platforms like Google Colab, Replit, PythonAnywhere and more provide seamless online Python environments with various features and tools.

Where can I program Python? ›

Top Python IDEs
  • IDLE. IDLE (Integrated Development and Learning Environment) is a default editor that accompanies Python. ...
  • PyCharm. PyCharm is a widely used Python IDE created by JetBrains. ...
  • Visual Studio Code. Visual Studio Code is an open-source (and free) IDE created by Microsoft. ...
  • Sublime Text 3. ...
  • Atom. ...
  • Jupyter. ...
  • Spyder. ...
  • PyDev.
Apr 15, 2024

Where can I write a Python code? ›

PyCharm, Spyder, and Thonny are among the most popular ones. PyCharm is a full-featured IDE that supports Python development directly, with support for source control and projects.

Top Articles
Latest Posts
Article information

Author: Neely Ledner

Last Updated:

Views: 6484

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Neely Ledner

Birthday: 1998-06-09

Address: 443 Barrows Terrace, New Jodyberg, CO 57462-5329

Phone: +2433516856029

Job: Central Legal Facilitator

Hobby: Backpacking, Jogging, Magic, Driving, Macrame, Embroidery, Foraging

Introduction: My name is Neely Ledner, I am a bright, determined, beautiful, adventurous, adventurous, spotless, calm person who loves writing and wants to share my knowledge and understanding with you.