How to install Python in Windows

Posted on

by

in

How to install Python in Windows

Introduction

In this post we are going to detail the steps on how to install Python in Windows environment. Python is an interpreted language that is used in many fields such as Machine Learning, AI and even Microcontroller programming. So it is a good idea to start learning about this programming language.

Prerequisites

Any windows workstation with sufficient memory and cpu power to run the latest version of the Python executable.

Installation Steps

  1. Download the installer from this link. Select the latest version of the python executable.
Install Python Windows - Download page

If you are downloading to other OS such as Mac or Linux then click the dowloand section from that link as well.

  1. When the download for the executable is finished then click it.
  2. On the first screen, you can customize where you want your Python installation to be installed. I choose the default. Click also the checkbox “Add Python <version> to PATH“. This will add your python executable to the PATH Variable.
Install Python Windows - First Screen
  1. Setup will intialize. If user account control pops up then click Yes. Wait for the setup to finish.
Install Python Windows  - Initialize
  1. If everything goes well then the following message is displayed.
Install Python Windows - Finish
  1. To test out your new Python Installation, open a command prompt and then type in the following code. You should be able to see your latest Python Version. Congratulations you have successfully installed Python and you are now on your way to become a Pythonista.
C:\Users\DONSKY>python --version
Python 3.10.6

Uninstall Python in Windows

To uninstall your Python then go to Settings – Apps and Features. Click the uninstall button.

Windows  - Uninstall Program

If the folder where you installed python is not deleted then safely delete it by opening a command prompt in Administrator mode and then execute the following command.

cd <Python Installation Dir>
rmdir /s Python

Issues

How to set default Python in Windows?

While other OS like Unix or Linux had default system supported installation of Python, Windows does not have this feature. For example, you can have multiple Python Version in your workstation. Example is a Python 2.7 or Python 3. They both have the same python executable so how do you set the Python that you want?

First find out if you have multiple Python.exe executable in your windows. To know this, execute below command “py -0p”

C:\Users\DONSKY>py -0p
Installed Pythons found by py Launcher for Windows
 -3.10-64       C:\Users\DONSKY\AppData\Local\Programs\Python\Python310\python.exe *
 -3.9-64        C:\ProgramData\Anaconda3\python.exe

In my workstation, I have an Anaconda installation and the latest Python that I have installed.

To select which version I want to run then I am doing the following option

C:\Users\DONSKY>py -0p
Installed Pythons found by py Launcher for Windows
 -3.10-64       C:\Users\DONSKY\AppData\Local\Programs\Python\Python310\python.exe *
 -3.9-64        C:\ProgramData\Anaconda3\python.exe


C:\Users\DONSKY>set PATH=C:\Users\DONSKY\AppData\Local\Programs\Python\Python310; %PATH%

C:\Users\DONSKY>python --version
Python 3.10.6

C:\Users\DONSKY>set PATH=C:\ProgramData\Anaconda3; %PATH%

C:\Users\DONSKY>python --version
Python 3.9.7

This will create a temporary local PATH variable in my command prompt so that I could select which Python version I want to run.

Wrap Up

We have explored the steps on how to install python in your windows environment in this post. Python is a good programming language and is easy to begin with for first time programmers.

Happy exploring!

If you like my post then please consider sharing this. Thanks!

Leave a Reply

Your email address will not be published.