Like Java, Python is another programming language that developers use to build software and web applications. Many developers prefer working with Python because of its simple syntax that is easy to write and understand. Financial institutions, movie studios, IT sectors, video game companies, artists, and many other people use Python for different application building purposes. No doubt, Python is easy to understand and use, but it is a high-class programming language and has a wide array of use cases. Learning it takes patience and passion. But that is for another time; in this article, we will simply help you learn how to install Python on your Windows machine.
Python comes by default in Linux distributions, but it has to be installed separately on Windows OS. Nonetheless, it’s easy to install Python on your Windows machine or local client as it only requires you to follow a few steps. However, before we start with how to install Python on Windows, there are some prerequisites that you need to know.
Prerequisites for Installing Python
You can download Python on your Windows from the Python.org website. But before you do so, let’s take a note of a few important things:
- Make sure your computer is running Windows 10 with admin privileges.
- You should have basic knowledge of working with command prompt.
- If you are installing Python on a remote desktop server, you will require a Remote Desktop Connection app.
Once you are on the Python.org website, go to the Downloads tab and click on the Windows option. Click on the Download button to download the latest version of Python on your computer. You can also click on the Downloads menu button and find a specific version of Python (such as 3) on the downloads page.
Step-By-Step Guide for Installing Python on Your Windows Machine
Step 1: Select the Right Version of Python
The version of Python you need depends on your project type. If you are working on a code in Python version 2.6, you will need that version only. But if you are starting a project without any prior limit or restrictions, you can choose whatever version you require. Developers who are learning to code in Python can download both versions 2 and 3. You can work on older projects if you have Python 2, and work on newer projects with Python version 3. Also, Python has backward compatibility so you may still be able to work with old Python projects using Python 3.
Step 2: Download Python Installation Package
You can download the Python installer from the Downloads for Windows section on the Python website, and you can search for your appropriate Python version there. In addition, you can also download Windows x86-64 executable installer or Windows x86 executable installer. And since the installer package is not very large, you can download it quickly.
Step 3: Install Python
Once you download the Python.exe installer on your computer, you can immediately start the installation. You will have to open the installer and run it to install the package. However, before you install Python on your computer, select a default installation location first. Remember to check the “Add Python to PATH” box; otherwise, Python applications won’t be able to find the Python on your system.
Applications written in Python need all the files installed by the Python installer to run. Therefore, it’s important for them to find the exact and proper location of Python on your systems. Thus, it’s important to click on the Add Python (version) to PATH option before clicking on the Install Now button.
The User Account Control system menu will appear where you will have to click Yes to get approval from Windows to install the Python installer. Now, Windows will distribute the files to the Python package into a suitable location, and you will have to wait a few minutes for that to complete. Once done, you can go ahead and follow the next steps.
Step 4: Install an IDE
The new versions of Python will require you to install an IDE and pip, but older versions may not require these. Check out how to install the pip and IDE.
IDE or integrated development environment is a software program that integrates a source code editor that lets you write and modify Python code and also offers features like a built-in debugger, auto code completion, etc. There are two highly popular IDEs that you can use to work on your Python projects, namely IDLE and PyCharm IDE.
Every Python installation incorporates an Integrated Development and Learning Environment (IDLE). It is basically a class of applications that helps you to write codes more efficiently, with less chances of errors. There are other IDEs available on the market, but if you’re a beginner, IDLE is the best choice for you. With features like keywords highlighting, typos detection, easy code testing, and more, IDE offers you the easiest solution to work with Python codes.
To start with IDLE, click on the Start icon of your WIndows or press the Windows button and type ‘python’ in the search bar without quotes. Then, launch IDLE from the results. If you don’t see Python in the search results, you will have to reinstall Python and make sure you have selected the PATH while installing the tool.
2. PyCharm IDE
The PyCharm IDE is kind of an advanced version of IDLE. It’s used by professional developers. PyCharm is an open-source Python IDE that contains all the features IDLE has and a little more than that. PyCharm helps you avoid syntax errors, line numbers, indentation markers, and the ability to test codes easily.
To get PyCharm, go to the PyCharm IDE website and download their installer, then run it on your system. Install it the way you installed Python on your system. Once installed, you can double-click it from your desktop, and it will launch.
Step 5: Verify if Python was Successfully Installed
After the installation, you can verify if Python was installed successfully on your Windows. Just follow the steps below:
- Navigate to the directory where you have installed Python. For example, C:\Users\Username\AppData\Local\Programs\Python\Python37
- Find the executable file and double-click on python.exe
- If it was installed, you would see the output similar to below: Python 3.6.6.
Note: If you’re using an old version of Python, pip might not be installed.
- To verify if pip was installed put the command: pip –version will appear
- To make sure you have the latest versions, update pip and wheel by using the command: pip install –upgrade pip wheel
Alternatively, you can verify if the pip was installed by using the command prompt. If you have installed the older version of Python, it is possible that pip didn’t come along. You can check if pip was installed by pressing the Windows button and typing “cmd” in the search bar. The command prompt will appear and you need to open it. Now, type pip -V to see if pip was installed successfully. If you get this output:’ pip’ is not recognized as an internal or external command, Operable program, or batch file, it means that pip isn’t installed.
Pip is a powerful package manager for Python modules. Modules are the python code libraries that you might want to add to your project. Therefore, installing pip is important when you are working in a virtual environment. You can go to https://pypi.org/project/pip/ for installing pip on your Windows from there.
Step 6: Add Python Path to Environment Variables
If you have not selected the Add Python to PATH checkbox at the beginning of Python installation, you need to add the Python path to environment variables manually. Setting up the PATH for Python helps Windows to look for Python in the exact path instead of searching all over the computer. Here is what you need to do to add Python Path to environment variables:
- Press the Windows button and search for Run.
- When the Run box appears, type sysdm.cpl and click OK.
- Now, the System Properties window will appear.
- Visit the Advanced tab and select Environment Variables.
- Under the System Variables, find the Path variable and select it.
- Click on the Edit button.
- On the Variable value field, add a semicolon (;) and the Path to the python.exe file. For example, “C:/Python34.”
- Click on OK and close the windows
Now you can execute Python scripts like this: Python script.py instead of this: C:/Python34/Python script.py.
Step 7: Optional Steps: Install virtualenv
With virtualenv, you can create isolated local virtual environments for your projects in Python. But why do you need virtualenv anyway? The Python software is installed system-wide by default mechanism, and when you change a single package, it changes all Python projects. By creating individual virtual environments, you can avoid changes to apply globally for all Python projects. Here, follow the steps to install virtualenv:
- Press your Windows button and type “CMD” in the search field.
- Open command prompt window.
- In the command prompt window, type the following pip command:
C:\Users\Username> pip install virtualenv.
This will install virtualenv on your computer.
No matter what version of Python you want to install on Windows, all will follow the process that we have demonstrated in this guide. Just remember to select your Python version carefully, which usually depends on the type of project you want to work with. Also, you need to install pip and virtualenv to manage your Python projects with ease.