Python has become one of the most popular programming languages. It has its application in many fields. Installing Python is the first step towards becoming a python programmer in 2021.
This article will provide you with a step-by-step visual guide to install Python 3.9 on Windows 10 and Mac OS.
Since 2020, Python 2 has already become obsolete. The whole world has switched to Python 3 and for all the right reasons. So I would request you to not work with Python 2 anymore!
Another important thing to note is your Windows system. Many of the Python versions cannot be used on Windows XP or earlier.
To install the latest version of Python, ensure you have the latest or updated version of Windows 10.
The below instructions and images are for Windows 10, but they work for Mac OS too.
Python installation instruction in short
- Visit the official website of Python
- Step 2 - Download the latest version of Python
- Step 3 - Installation Process
- Step 4 - Successful Setup
- Step 5 - Check your Python version
- Step 6 - Hello World!
Step 1 - Visit the official website of Python
Visit the official website of the Python Programming language and click on Downloads.
The website will automatically detect your operating system. So, it will show you the appropriate installer for your machine.
Step 2 - Download the latest version of Python
Once you are on the downloads page, click the button for the Latest Python 3 Release - Download Python 3.x.x. On the day of writing this article, the latest version was Python 3.9.1.
Once you click on the Download button, the installer should be downloaded.
Step 3 - Start Installation
Double click on the installer to start the installation process for Python 3.9. It will open up a dialog box as shown below.
Make sure to check the dialog box for “ADD Python 3.9 to PATH”, present at the bottom of the dialog box.
Why should you add Python to PATH?
PATH is an environment variable in Windows. It basically tells your Windows machine what folders to look in when attempting to find a file. By adding Python 3.9 to PATH, you will be able to execute the Python interpreter from any directory in your system.
Then click on Install Now. You should see the installation process begin.
Step 4 - Successful Setup
If your installation process ran fine, you should see a Successful Setup message like below. You can close the dialog box after this message.
You are now ready to run Python.
Step 5 - Check your Python version
Open your command-line terminal and type
python --version. You should see the version of Python that you have downloaded.
Step 6 - Hello World!
python on your command line terminal and press Enter. This opens an interactive session of Python 3.9 on your terminal In your interactive session, type
print("Hello World!") , and press Enter.
Now you can run any kind of python code in this interactive session. Try doing some mathematical calculations and see how Python works with arithmetic operators.
Where is Python installed on Windows?
In general, Python is installed in \Users\[Your Username]\AppData\Local\Programs\Python\[Python Version]\ directory of your Windows machine.
But in doubt, you can use the
where python command on your command line to find out the directory in which Python is installed.
Can you have more than one version of Python installed?
From the above image, you can notice that I have more than one version of Python installed on my Windows 10 machine.
Do you need it too? Probably not!
There are certain scenarios, where it might be useful to have multiple versions of Python.
- When you are working on different projects that use different versions of Python. This is a very common scenario for a freelancer.
- When you are working with a particular 3rd party library and it only works with specific Python versions.
- When you are building a cool Python library for others to use, having multiple versions of Python can help you test it against each of those versions for different points of failure.
The second point is actually a very common reason to have multiple versions of Python installed on your machine. It is actually recommended to choose a Python version that is one version behind the current one for a better 3rd party library compatibility.
If you are a beginner, don't bother with multiple Python installations. One is enough!
If you have multiple Python versions installed, you could uninstall one of those by following 3 simple steps. Check out the article on Uninstalling Python 3 from Windows 10.