How to Setup Python Environment Variables In Windows 10

Python is a well-known high-level programming language that has been around since 1991.

It is thought to be one of the server-side programming languages with the most flexibility.

Unlike most Linux distributions, Windows does not come with Python installed. However, you can easily install it in just a few steps.

How to get and set environment variables in Python: Python 3 Installation on Windows

It’s not hard to install and setup Python environment variables on your personal computer. It will only take a few easy steps:

Step 1: Download the Python Installer

Option 1: Download using the Microsoft Store

Did you know that the Microsoft Store may also be used to install Python on your computer?

To install Python using Microsoft Store do the following:

  • In the start menu, type or search for “Microsoft Store”.
  • Once the Microsoft Store is open, search for the word “Python”

The Microsoft Store has several versions of Python. If you are unsure of what you are doing, it is best to use the most recent version.

Python in Microsoft Store Installation

You can access and choose a different version of Python inside the Store and it is free to download software.

Python in Microsoft Store Installation Python 3.10

  • Click the desired version of Python, then click “Get“, your Windows computer will now have Python installed.

When the installation is done, click the Start button and you should see that Python and IDLE have been added to your list of recently installed programs.

The Microsoft Store package for Python 3.10 is published by the Python Software Foundation and is easy to install. It is mainly intended for interactive use, such as by students.

Warning: If you are asked to pay for Python, you have not selected the correct package.

Option 2: Download using Windows Installer

The installation procedure involves downloading the official Python .exe installer and running it on your system.

  • Then choose to download the Windows installer that corresponds to your system type (32-bit or 64-bit).
Python releases for Windows

Step 2: Run the Executable Installer

After downloading the installer, execute the Python installer.

  • Make sure to check the “Install launcher for all users” check box. Additionally, you may check the Add Python 3.10 to path check box to include the interpreter in the execution path.
  • Select “Customize Installation” to continue.
Python Installation

  • By selecting the checkboxes below you will be redirected to the Optional Features:
Python Installation - Optional Features

  • Select Next.
  • You will see Advanced Options and select the Install for all users and Add Python to environment variables checkboxes.
Python Installation - Advanced Option

  • Click Install to start the installation.
  • After the installation, you’ll see a Python Setup successful
Python Installation - Setup was successful

Step 3: Add Python to environmental variables

In setting up Python, you must take this step to use Python from the command line.

If you set the Advanced options and added Python to the environment variables during installation, you can skip this step.

  • Search for “Advanced System Settings” in the start menu and select “View Advanced System Settings”.
Start Menu

Inside the “System Properties“, select the “Environmental Variables” button.

Advanced System Properties

  • Next is to locate the Python installation directory. If you follow our previous step above, you will locate your Python directory in this location:
C:\Users\Computer_Name\AppData\Local\Programs\Python\Python310

Python 3.10.5 Directory

The folder name of the Python location may be different if you installed a different version of Python.

  • Add the location of the Python installation directory to the Path Variable.
Python Environment Variables
Python New User Variable

Step 4: Verify the Python Installation

You have now installed Python 3.10.5 on Windows 10. To verify the installation, you can use the command line or the IDLE app.

  • In the start menu, search for the cmd or command prompt.
Python Verification

  • Once the Windows Command Prompt is open, type py and you will see this:
Python Verification - Using CMD

  • You can also use the IDLE (Python 3.10 64-bit)
  • In the start menu, search Python and select the IDLE (Python 3.10 64-bit)
Python Verification - Using Python IDLE

Step 5: Verify Pip Was Installed

Most Python packages should be installed with Pip, especially when working in virtual environments. To verify whether Pip was installed follow the steps below:

  • In the Start menu type “cmd“.
  • After you have opened the Windows Command Prompt, type pip -V into it.
Python Pip verification

Step 6: Install Virtual Environment (Optional)

In order to create isolated virtual environments for your Python projects, you will need to install virtualenv.

Why use virtualenv?

By default, Python software packages are installed on the whole system. So, when you change a project-specific package, all of your Python projects are affected.

You would want to avoid this, and the best way to do so is to have virtual environments for each project that are different from the others.

To install virtualenv:

  • In the Start menu type “cmd“.
  • Once the Windows Command Prompt is open, type the following pip command:
C:\Users\Computer_Name> pip install virtualenv

Virtual Environment Installation

Summary

In summary, we have learned how to install Python setup environment variables on Windows. Python works with many different operating systems, including Mac OS X and Linux.

Setting up PATH for Python Environment on operating systems offers a list of directories where the OS searches for executables.

Make certain that the Python environment has been correctly installed, setup, and is operating normally.


Leave a Comment