Skip to content

Python 3: Installation and Setup

Python 3 Installation and Setup Cover Image

Installing or upgrading Python is an important step in becoming a Python programmer. There are a number of different ways that you can install and upgrade Python. This tutorial will cover off using the official installer from Python.org and the excellent Visual Studio Code editor from Microsoft. Once you’re set up, you’ll be ready to start installing Python packages like pandas and numpy and dive into building your own Python applications.

In this tutorial, you’ll learn how to:

  • Check if Python is already installed on your machine
  • Install or update Python on Windows and macOS
  • Install and set up Visual Studio Code (VS Code) to run your Python scripts

How to Install Python on Windows

In this section, you’ll learn everything you need to get up and running with Python on Windows. While Python can be installed in a number of different ways, this tutorial will teach you how to install Python using the official installer. This is because this represents the official version that is maintained by the Python Software Founding.

How to Check if Python is installed on Windows

You can check if you already have Python installed on your computer by following the steps below. These steps can also be used to check what version of Python is installed on your computer.

  1. Open up a command-line application, such as cmd.exe. This can be done by hitting the Ctrl and r keys. Once the Run application opens, type in cmd and hit OK.
  2. Type in python --version.
  3. If a value is returned, then you already have Python installed. If not, you can follow the steps below to install the latest version of Python!

As of this writing, the most recent version of Python is 3.10.1. Let’s get started on either installing or upgrading your version of Python!

How to Install Python on Windows

In this section, you’ll learn how to install Python on your Windows machine. While there are a number of ways to install Python, you’ll learn how to install it via the official installer only. This is because this version is the one maintained by the Python Software Foundation.

Step 1: Download the Official Installer from Python.org

You can find the latest version by visiting the Python Windows Download Page. Scroll down the page to find the latest Stable release, which currently is Python 3.10.1.

Downloading the Stable Version of Python in Windows
Finding the latest stable version of Python for Windows

You’ll want to make sure you’re downloading the stable release unless you have a lot of experience with Python.

Installing 32-bit or 64-bit Python

On Windows, you’ll be given the choice to download either the 32-bit or 64-bit version of Windows. If you’re running a 32-bit machine, you have to install the 32-bit version. On a 64-bit machine, you can run either. The 64-bit version will consume more memory but also handle larger tasks more efficiently. Install the version of Python that matches your system.

Step 2: Running the Python Installer for Windows

Once you’ve downloaded the installer, you can double-click the installer to begin running it. This will open up an installer like the one shown below:

Installing Python on Windows
Beginning the Python Installation on Windows

For beginners who don’t know about what the PATH is, simply follow the recommended and default instructions to install Python. Simply click through the installation and Python will be installed on your machine!

Setting up VS Code on Windows

Visual Studio Code (VS Code) is a free application developed by Microsoft that can be used to write, edit, and run Python code. There are many other applications available to do this, but VS Code provides a great way to use and run Python. VS Code offers a ton of extensions (which you’ll learn to install later), themes, and more.

To download the installer, visit the official download page. Once the file is downloaded, you can run the installer. Simply follow the on-screen instructions to complete the installation. Once the program is installed, open it to begin using it.

Microsoft develops its own Python extension for VS Code. This extension enables you to run Python code and gives you access to a ton of other features, such as Intellisense and debugging. You can find the extension by selecting the Extensions menu on the sidebar and searching for Python.

Installing the Python Extension for Windows
Installing the Python extension on VS Code for Windows

Make sure the extension is the official one by Microsoft. Simply select install and VS Code will handle the installation for you. Once it’s installed, you can move to the next section to run your first Python script.

Running Your First Python Script on macOS

To run your first Python script, follow the steps below:

  1. Create a new file by clicking Ctrl and n.
  2. Save the file as helloworld.py
  3. Enter the following code into your code editor:
print("Hello world!")
  1. Click the run button at the top to execute your script
Running your first Python script on Windows in VS Code
Running your first Python script in VS Code on macOS
  1. The VS Code editor will open a terminal at the bottom of your script to output your code

Congratulations! You’re all set up to use Python in VS Code on Windows!

How to Install Python on macOS

In previous versions of macOS, Python 2 came preinstalled. However, beginning in macOS Catalina, this changed and no version of Python was bundled with macOS. In this section, you’ll learn how to install Python on macOS and set up Visual Studio Code to edit and run your Python scripts.

How to Check if Python is installed on macOS

You can check if Python is already installed on your machine by using a command-line application, such as Terminal. You can open the Terminal by going to your Applications folder, accessing the Utilities folder, and launching Terminal.

When you are in the command line application, you can check if Python 3 is installed by writing the code below:

python3 --version

If the application returns any version of Python 3, you have a working version of Python 3 installed on your system! If you want to install the latest version of Python, you can follow along with the guide below to upgrade your version of Python. If nothing is returned, follow the steps below to install Python.

How to Install Python on macOS

In this section, you’ll learn how to install Python using the official installer from the Python.org website. The benefit of the installer is that it is maintained by the Python Software Foundation. It also includes all the dependencies you need to get up and running with Python.

Step 1: Download the Official Installer from Python.org

To download the installer from Python.org, visit the Downloads page for Python. From there, you can navigate to the Stable Releases section to find the latest. At this time, the most current release is Python 3.10.1.

Finding the Latest Python Version on macOS
Identifying the latest stable release of Python for macOS

Be mindful to choose a stable version, unless you’re very familiar with what you’re doing and want to test experimental features.

Step 2: Running the Python Installer

Once you have the installer downloaded, you can run it by double-clicking the file. This will open the following window:

Starting the macOS Python Installer
Starting the official installer for Python on macOS

Simply follow through with the steps with the default settings. Using the default settings allows you to set up Python in the recommended way. Tinkering with the settings can have unintended consequences. Once the installation is complete, you’ll be presented with this window.

Python Installer macOS Complete
Python is successfully installed on macOS

Congratulations! You’ve successfully installed or upgraded your Python installation.

Installing VS Code on macOS

Visual Studio Code (VS Code) is a free application developed by Microsoft that can be used to write, edit, and run Python code. There are many other applications available to do this, but VS Code provides a great way to use and run Python. VS Code offers a ton of extensions (which you’ll learn to install later), themes, and more.

To download the installer, visit the official download page. Once the file is downloaded, simply double-click the zip file to open the archive. From there, drag the application to your application folder.

Setting up VS Code on macOS

In order to make full use of VS Code’s Python support, you’ll need to install your first extension! This extension is the official Python extension provided by Microsoft.

You can find the extension library by selecting the Extension menu in the application. From there, search for python in the search bar. The first option should be the official version from Microsoft but double-check the publisher. Click Install to install it and after a few moments, the extension will be ready to use.

Finding the Python Extension for VS Code
Finding the official Python Extension from Microsoft in VS Code

Running Your First Python Script on macOS

To run your first Python script, follow the steps below:

  1. Create a new file by clicking command and n.
  2. Save the file as helloworld.py
  3. Enter the following code into your code editor:
print("Hello world!")
  1. Click the run button at the top to execute your script
Running Your First Python Script on VS Code on macOS
Running your first Python script in VS Code on macOS
  1. The VS Code editor will open a terminal at the bottom of your script to output your code

Congratulations! You’re all set up to use Python in VS Code on macOS!

Conclusion

In this tutorial, you learned how to install Python on both a Windows computer and a macOS computer. You learned how to install the official Python version from the Python Software Foundation. You also learned how to set up Visual Studio Code on both Windows and macOS, including how to set up the Python extension. You’re now ready to start writing and running your own Python scripts!

Additional Resources

Check out the tutorials below to learn about related topics:

Tags:

Leave a Reply

Your email address will not be published.