Learn how to access Python from anywhere on the command line by adding it to your Windows PATH variable.
Running Python from the terminal is often unavoidable. However, if you just installed Python on Windows 10 for the first time, running it via the Windows Terminal is only possible if it’s added to the Windows PATH environment variable.
It can seem tricky to do, but it’s nothing to fear. To help you overcome the twists involved in adding Python to the Windows PATH after installing it, let’s take a look at the options and the few steps involved.
Why Add Python To Windows PATH?
If you fail to add Python to the PATH on your Windows OS, you can’t run the Python interpreter, start a virtual programming environment, or run commands like pip install from the terminal.
That’s because, when you run any non-default program from the command line, the machine looks for an executable in the current folder, or in the Windows PATH.
If it’s not in the PATH variable, the terminal returns a “command not found” error. Adding to the PATH is powerful, even if you’re executing a command from a created or default batch file, adding its parent execution file to the PATH variable makes it callable from the terminal as well.
How To Manually Add Python To The Windows PATH
First off, if you’ve not installed Python on your machine, go to the python.org website to download and install your preferred version.
Once Python is successfully installed on your PC, check if it’s already added to the Windows PATH. Open up your terminal and type python, then hit the Enter key. The command might return an error that says “‘python’ is not recognized as an internal or external command, operable program or batch file,” indicating that Python isn’t added to your machine’s PATH variable yet.
To execute Python programs from your command line, follow the steps highlighted below.
Find Python’s Installation Path On Your PC
To add Python to your Windows PATH, you need to get its installation path. To do that, open up the Windows search bar and type python.exe (don’t hit the Enter key). Then right-click on Python.exe that pops up in the resulting menu and select the Open file location option.
In the Explorer windows that opens, click on the long directory bar to the left of the search bar. Highlight and copy the entire path text to your clipboard with Ctrl + c. Then continue with the next steps below.
Next: Add Python To PATH In User Variables
To add Python to the PATH in User variables, right-click on This PC, and select Properties. Once in the properties menu, click on the Advanced system settings option. In the next window, select the Advanced tab, and select Environment Variables.
The Environment Variables menu has two distinct parts: an upper part called User variables, and a lower part named System variables. However, our focus is on the User variables in this case.
Within the User variables menu, locate a variable called Path. Then paste the path you copied earlier in the Variable value option using Ctrl + v and click Ok.
However, if you can’t find that variable, you might need to create it. To do that, click on New. Next, in the Variable name form, type Path, and paste your Python path in the Variable value field.
The post How to Add Python to the Windows PATH variable appeared first on How To Get Job.
from WordPress https://howtogetafreejob.com/how-to-add-python-to-the-windows-path-variable/
0 Comments
If you have any doubts , Please let me now
Emoji