Add “python2” path to command line on Windows 7
Solution 1
This answer copied from my own answer, and customized to this question.
Try following command.
set path=%path%;c:\python27
PATH
is set only for the cmd.exe in which you run the above command.
To permanently set PATH:
- Right click My computer in the desktop.
- Click Advanced System Settings on the left.
- Click Environmental Variable.
- Add or Update
PATH
variable:- If it does not exist, create one, and set value as
C:\python27
- If it exist, append
;C:\Python27
to existing value.
- If it does not exist, create one, and set value as
- Restart cmd.exe. (PATH will not change for already launched cmd.exe)
UPDATE
If you want to use python2, copy the executable.
CD C:\python27
COPY python.exe python2.exe
Solution 2
Had the same problem and fixed it...
I have C:\Python27
, which i have added to my environment variables which gave me access to "python" though the CMD.. but for installing node-sass though npm, which was my problem, it continues to say that "python2" is not found. A friend the told me i could just rename name executable, which i didn't belive, but it worked :-)
The rename was from:
C:\Python27\python.exe
> C:\Python27\python2.exe
It works for me, even though it find it weird just renaming a file.. but then, i am not hardcore in the windows CMD.
Related videos on Youtube
Admin
Updated on July 17, 2022Comments
-
Admin almost 2 years
I've been trying to add the
python2
path to command line on Windows 7.I have tried to do it this way:
C:\>set python2 = C:\Python27\python.exe
But
cmd
told me that:'python2' is not recognized as an internal or external command.
So how can I add
python2
path to command line on Windows 7?Thanks.
-
falsetru over 8 years@downvoter, How can I improve the answer? Please let me know what's wrong with the answer. I want to listen.
-
pohl about 6 yearsI'm not the downvoter, but it appears that the question is asking how to make the
python2
command appear in thePATH
, but your answer shows how to getpython
into thePATH
instead. I'm guessing the user has a script that is trying to specifically invoke Python2 in a mixed Python2/Python3 environment. -
Julian Wise over 5 yearsThis feels like it absolutely should not be the correct answer. That said with my environment variables set correctly all that required was to change the name of the executable to python2.exe and it worked! Upvote to you! Cheers
-
Banketeshvar Narayan almost 5 yearsI just make a 2nd copy of python.exe with name python2.exe and it works for me. Thanks for you solution. Upvoted to you.
-
Schalton about 3 years2/7/21 and node-sass is still using pyhton2 smdh
-
typhon04 about 3 yearsI second @BanketeshvarNarayan 's comment. Seems like pip2 looks for the location of python.exe file.. so having two copies of the exe (python.exe and python2.exe) seems to work fine.
-
rook218 almost 3 years@Schalton I'm hitting the same problem and can't believe that it's still an issue. All because there's a
print
command using python 2's syntax... If I didn't just waste enough time to get behind on this project trying to figure out the solution, I'd make a pull request myself... -
Krushn Dayshmookh over 2 yearssimply copying the executable solved the problem
-
adir abargil about 2 yearsdoes this override the
python
for python3.* command? -
afterxleep about 2 yearsSplendid. Simple, obvious (when you realise it) and brilliant.