Python is a computer language that may be used for web development, data analysis, machine learning, statistics, and web scraping, among other things. There are a lot of tutorials available, which makes it difficult to recommend one. There is, however, inadequate support for Windows. This article will demonstrate how to set up and use Python on Windows.
Installation Pythons on Windows
Go to the Python website and download the most recent version of your operating system.
Then, by double-clicking the installer (the downloaded file), launch it.
You’ll come across a window that looks like this:
From this stage, you should check the box that says “Add Python 3.10 to PATH” if you want to keep accessing Python from your command prompt.
Now, allow the installation process to be complete. It’ll look like this while in progress:
When the installation is complete and doesn’t return any errors, you’ll see this (or something similar):
Also, it is recommended that you click on “Disable path length limit” if you will keep using the cmd to access your Python codes.
The main reason for disabling the path length limit is, if your Python code is located in a folder deep within your computer (and has a “PATH” name longer than 260 characters), Windows may refuse to allow it to execute without it.
Now type “cmd” into the Windows search box at the bottom of your screen. When you open the “Command Prompt” program, a black box should appear (assuming you have no idea what a command prompt is).
Type in the following and hit enter:
You should see something like this where the “3.10.2” (that’s the latest version as at the time of writing this) appears after running the command:
Solution 1: How to Add Python to Your PATH Environment Variable
As we have shown above, typing “Python –version” should show the version of python you are running on your PC. However, in situations where you have multiple drives in your computer and the drive where Python was installed, is entirely different from the drive where your Operating System is loaded (which is where your CMD will be loading from), then you’ll need to manually enable your CMD to see and recognize the presence of python on your computer.
Here’s what you’ll most likely be welcomed with:
In this situation, Python was installed on “Drive D:”, while the Operating System was installed on “Drive C:”. To solve this, you’ll first need to access the installation location of Python on your PC.
Steps To Access Python on Your Computer
The first method to access Python on your computer is to follow the path of the installed software and access the executable file directly. To do this, follow the steps below:
Step 1: Open your Windows Menu and search for “Python” (without the quotes)
Step 2: Right-click on the file that has “App” indicated under it. This shows it is the launchable file. After that, click on “open file location”
Opening the file location shows the shortcuts to access python and its resources. But that’s not what we are after.
Step 3: To get the actual executable file, right-click on “Python 3.10” (in this case) and click on “open file location” as well.
This should take you to the page where you’ll see the executable file as shown below:
Step 4: Now, copy the address of the python executable by clicking on the address bar on top of the page, ensuring that you highlight everything, then pressing CTRL + C to copy.
Step 5: After copying, go to your system’s properties by right-clicking on an empty space in “This PC” (assuming you’re using Windows 8, 10, or 11).
As shown in the picture above, click on “Advanced system settings”
Step 6: On the Advanced tab, click on “Environment Variables”
Step 7: Click on “Path”, then “Edit” to add a new path
Step 8: Click “New”, then paste the address you copied that points to the executable file from Step 4.
If you don’t want persistent access to Python through cmd, copy the address from Step 4, put it in the command prompt, add a backslash (\)”, and type ‘python.exe’, then press enter.
You should be able to have access to python temporarily.
However, you will have to copy the path into the command prompt every time you launch Python using this way. This procedure might be time-consuming and difficult. We propose that you use the first option to avoid all of these problems.