In this Python tutorial, we are going to learn How to add Python to Windows Path. Here we will show you two methods to add Python to the windows path.
In the previous Python programming article, we have seen How to install Python’s latest version in different operating systems like Windows, Ubuntu, and macOS.
In this guide we will see How to add python path to windows environment variables step by step, If you want to run python program on terminal then it is mandatory to add Python path to windows 10 path.
Here we will see two methods to add python path to CMD ( Terminal ) to execute Python program on terminal. This article will only helpful for windows users who getting error after type Python on command prompt. if you are getting following error, Don’t worry, at the the end of this article we are able to execute Python program using terminal.
To solve above error completely you have to add Python to Windows Path.
There are two ways to add Python path to windows environment variables.
- Add Python to Windows Path at Installation Time.
- Add Python Path to CMD ( Terminal) manually.
Add Python to Windows Path at Installation Time.
This is best ways to solve this error because when you install Python in your machine, Then a option appear to add Python Path to Windows path. When you checked that option, Then Python path automatically add to your windows environment variables.
If you want to learn How to add Python to windows path at installation time, then click below link and learn that article.
Add Python Path to Windows manually.
This is manual way to solve this problem. When you have already installed Python in your machine and getting bellow error, Then you can follow these steps.
‘python’ is not recognized as an internal or external command,
operable program or batch file.
Let’s how can you add Python to windows path manually.
1. First, Right click on This PC icon and click on Properties.
2. Click on Advanced system settings.
3. Click on Environment variables to add Python to windows Path.
4. To add Python path to Windows environment variables , you have to click on new.
5. There are two options available to add Python path.
- Variable Name
- Variable Value
6. Now, navigate the directory where Python installed and copy that path. After that, you have to copy Scripts directory pat.
In my case, the Python installed directory is shown in the below screenshot. In your case maybe this directory the same or different.
7. Now, you have to set the value of the Variable name as Path, and the value of Variable value is copied python installed directory path and Scripts directory path separated by a semicolon ( ; ) and click Ok.
This is how Variable value look like this.
8. Now keep clicking on the OK button until Windows is finished.
9. To check whether, Python path successfully added in your machine environment variable, you have to open your command prompt and type Python. If you are getting below interface, Then you have successfully added Python to windows path.
So these are the manual steps to add Python Path to windows path.
Let’s see run simple python program on terminal. We will print simple message to check Python successfully work or not.
print('Python successfully added to windows path')
In this tutorial, you have learned how to add Python to windows path in two different ways. if you are getting above error, then this is the only method two solve the error.
After add Python path to windows environment variables you can run any python program using terminal ( CMD ).
I hope this article will have helped you. If you like this article please share who face this error. If you want to become Python programmer, programming Funda is best place to learn Python where you can find various technology and grow your knowledge.