Skip to content Skip to footer

How to install Python and VS Code on Windows?

Do you want to learn a programming language with a gentle learning curve, which can be applied in a variety of fields? Python is the programming language for you! Python is used for building web applications, automating tasks, machine learning & data science and in many more fields!

Installing Python locally or running it in the cloud?

This guide will walk you through the steps of installing Python locally (on your PC). However, you can also run Python in the cloud, which doesn’t require a local installation. Read my article about the easiest way to get started with Python if you want to skip the installation steps and run Python in the cloud.

Python installation

Luckily, installing Python locally is easy! Just navigate to Python’s official website and click on the “Download” button in order to download the latest version. At this moment (March ’24) the latest version is 3.12.2.

You can walk through the installation steps of Python just like you do with any other application, there’s only one thing which is important: make sure you enable the checkbox “Add Python.exe to PATH” (see below image).

Why adding Python.exe to PATH is important (and what to do in case you missed it)

If you don’t enable the checkbox “Add Python.exe to PATH”, you will not be able to run Python.exe from any folder in your Windows installation. In case you missed the checkbox during the installation process, you can find the steps for adding Python.exe to PATH manually at the bottom of this article.

An editor or IDE?

You can create Python scripts in almost any editor. Even MS Windows’ default Notepad allows you ton create Python scripts! However, a good editor will make your life a lot easier! An editor provides code highlighting and enables you to integrate extensions such as Github Copilot. There’re also editors which integrate with complete development environments, such as PyCharm. We call those IDE’s (Integrated Development Environment).

I prefer to use VS Code, which is somewhere in between an IDE and an editor. It’s a free editor which you can extend with plenty of Extensions. If you’re just starting with Python, I would recommend to try VS Code first. You can always switch later.

Installing VS Code

You can download VS Code for free here. Just select your Operating System (Windows) and follow the installation steps.

Opening a folder in VS Code

VS Code is based on folders in Microsoft Windows. So for every (small) project you create, a recommend you to create a folder.

The next step is to navigate to “File > Open Folder” in VS Code and select this folder.

Now you can create a file with the Python extension (for example “main.py“)

Now type some code, for example the below code to put “Hello World on your screen” (we’re not printing anything ;))

print("Hello World")

After you insert this code, VS Code will recognize it as Python and suggest you to install the Python Language Support Plugin, which has some additional features such as code formatting etc. I recommend you to install this extension as well.

If VS Code is not suggesting this automatically, you can navigate to the “Extensions” sheet in VS Code (see the small red rectangle). And search for the plugin yourself (larger red rectangle in below picture).

What if you missed the checkbox for installing the PATH variable?

As mentioned earlier, it’s crucial that the PATH to Python is added to Windows. If you have followed the below steps you can skip this part. In case you missed the checkbox for adding the PATH variable to Windows, please follow the below instructions:

Adding the PATH variable for Python manually

Open Windows Explorer, right click on “This PC” and click on “Properties”.

Next, click on “Advanced System Settings”

Click on “Environment Variables”

In the dropdown, select “Path”, click on “New” and add the following:

C:\Users\[YOUR USERNAME]\AppData\Local\Programs\Python\Python312\

In the above expression, substitute [YOUR USERNAME] with your username. Also, “Python312” is referring to Python 3.12 (the current version). Please check whether this directory exists on your PC. If you installed a later version (e.g. 3.13) you might want to check if this folder exists on your PC.

If you don’t know your username, you can find it by opening a command prompt and typing whoami. The part after the backslash is your username.

After clicking on “Ok” to add the Path, you should be able to run Python code from anywhere on your Windows machine 🙂

Leave a comment

Receive my Python cheatsheet today!

Do you want to become a Python expert? I summarized all my expertise in a 3 pages cheatsheet, so you never have to Google again :)

Socials

Tom’s Tech Academy © 2024. All Rights Reserved.