Adding Python to windows PATH
Several individuals have issues while trying to work with python.
This may be attributed to lack of adding the PATH to windows... so lets solve this issue.
1st Methodology
Python 3.10 installers are available for download, two for each of the interpreter's 32-bit and 64-bit versions.
The web installer is a small initial download that will download the required components as needed.
The offline installer includes all of the components required for a standard installation.
Other ways to avoid downloading during installation can be found at Installing Without Downloading.
After launching the installer, one of two options is available:
Figure E.1. Python Installation window.
Clicking the 'Install Now' button.
The Python Launcher for Windows will be installed based on the option selected.
When you select this option, the installation directory is added to your PATH.
But if you do this :
Selecting 'Customize installation'
allows you to choose which attributes to install, where to install them,
as well as other alternatives or post-install actions. You must use this
option to install debugging symbols or binaries.
Select
"Customize installation" to perform an all-users installation. In this
instance:
1.) You may
be asked to provide administrative credentials or authorization.
2.) Python
will be placed in the Program Files folder.
3.) Python
for Windows will be installed in the Windows directory.
4.)
Optional features can be chosen during the installation process.
5.)
Pre-compilation of the standard library to bytecode is possible.
6.) If this
option is chosen, the install directory will be added to the system
PATH.
All users
have access to shortcuts.
2nd Methodology
This method checks to see if the PATH has already been added.
Follow these steps to determine whether or not the path setting is correct or current.
Open the administrative command prompt by following the steps outlined below:
Start >> Windows System >> Command Prompt |
Figure E.2. 'Command Prompt' window.
Then, on the command prompt icon, right-click and select Other> Run as administrator.
Enter a Python command after typing it.
If the system variable path is correctly set, you should get the output shown below.
Figure E.3. desired output from 'Command Prompt' window.
You can do the same using 'windows power shell'.
Figure E.4. desired output from 'Windows PowerShell 'window.
If the command has not been added to the path directory, you will receive an error stating that it is unknown.
However, you can see that Python has been installed and that you can boot from that directory.
3rd Methodology
This method involves changing the PATH manually if the issue has been found.
Follow these steps to ensure the problem is sorted.
To begin, press Win+R to open the run dialog box, then enter sysdm.cpl.
The System Properties dialog box will appear.
Figure E.5. Screenshot of 'Run' window.
On doing this you will be directed to a window like this.
Figure E.6. Screenshot of 'System Properties' window.
From here click on the "Advanced" toolbar as shown above, this will open the indented window.
or you can also do the following:
Right click on the Windows icon.
Figure E.7. Screenshot of 'Windows' right click action.
Select System as highlighted.
By doing this you will get a another window open where you have to select "Advanced system settings".
Figure E.8. Screenshot of 'Advanced system settings' from settings window.
Another window called "System Properties" will open, from where select "Enviroment Variables..".
Figure E.9. Screenshot of 'System Properties' proceed to Enviroment Variables.
We'll add a new User Variable. Select the New option.
Figure E.10. Screenshot of 'Enviroment Variables'.
Figure E.11. Screenshot of 'New User Variable' from Enviroment Variables window.
put your desired value under "Variable name:" (I suggest some recognizable value like 'Python')
put the path in "Variable value:" C:\Users\*username*\AppData\Local\Programs\Python\Python38 (change the variable value to match your actual installation path).
A new window will be launched. We will create a New entry that matches the Path variable we created in step 5 by appending "Scripts" to the end of the entry as shown below.
C:\Users\*yourusername*\AppData\Local\Programs\Python\Python38\Scripts\
Figure E.12. Screenshot of 'Edit enviroment variable' from Enviroment Variables window.
To save the entries,
click the OK button in each of the three open windows.
We
can now confirm that we have successfully completed this task by opening
a new administrative command prompt window and typing "python" into it
(without the quotes).
Figure E.13. Screenshot of 'Windows Powershell' checking for valid python path.
You should not recieve any errors this time. :-)
Copyright © 2022-2023. Anoop Johny. All Rights Reserved.