Add python 2 to path

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.

asked Jul 27, 2013 at 18:13

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:

  1. Right click My computer in the desktop.
  2. Click Advanced System Settings on the left.
  3. Click Environmental Variable.
  4. 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.
  5. 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

answered Jul 27, 2013 at 18:15

falsetrufalsetru

343k57 gold badges684 silver badges608 bronze badges

4

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.

answered Aug 13, 2018 at 11:55

Thor A. PedersenThor A. Pedersen

1,0723 gold badges16 silver badges32 bronze badges

6

I don't know whether it can be switched or not while keeping both python2 and python3. But while working with python2 you can remove the "python3 path" from the PATH. Cause By default in windows python3 is selected if both are installed. So you can try this to use python2. then when necessary again add the "python3 path " to the PATH

answered Aug 11, 2018 at 6:18

although I add Python to path variable, it appeared further, I tried with Thor A. Pedersen's answer it worked, I found another way without rename python.exe to python2.exe, just update your node config as bellow. It worked for me.

npm config set python python2.7 or npm config set python python

answered May 27, 2020 at 7:04

AsankaAsanka

4526 silver badges11 bronze badges

Wait until install is complete.

Add python 2 to path

Click Finish

Add python 2 to path

3. Download python3

In the same way as described in step 1, download python3.

Add python 2 to path

Click on executable to install and choose ‘Customize installation’.

Add python 2 to path

Select default values and customize install location to C:\Python3

Add python 2 to path

4. Add python27 and python3 PATH

Search ‘Panel de control’ and open it.

Add python 2 to path

In the search bar, search for ‘variable de entorno’.

Add python 2 to path

Click on ‘Variables de entorno’

Add python 2 to path

Select PATH and click on ‘Nueva’

Add python 2 to path

Add the following routes in order to use python and pip.

C:\Python27

C:\Python27\Scripts

C:\Python3

C:\Python3\Scripts

Note: If you have installed python on a different location you need to find your where python is and set that location.

Add python 2 to path

5. Change executables names

In order to execute both python version change the python.exe to python2.exe where python2 is located and python.exe to python3.exe where python3 is located.

Add python 2 to path

Add python 2 to path

Add python 2 to path

Source: https://stackoverflow.com/questions/3809314/how-to-install-both-python-2-x-and-python-3-x-in-windows-7

6. TEST Both Python versions

a. Check python versions

Run Python2 –V and Python3 –V to get respective python versions.

Add python 2 to path

b. Install a package using python2 and python3

If the above commands run without problems python2 and python3 were successfully installed on windows 10 environment.

Add python 2 to path

Jose Miguel Arrieta

January 2018

How do I add Python to my PATH?

The complete path of python.exe can be added by:.
Right-clicking This PC and going to Properties..
Clicking on the Advanced system settings in the menu on the left..
Clicking on the Environment Variables button o​n the bottom right..
In the System variables section, selecting the Path variable and clicking on Edit..

How do I install Python 2?

Procedure.
Download the latest Python 2 (64-bit) installer from Python downloads for Windows, usually named Windows x86-64 MSI installer. ... .
Install Python 2: ... .
Check Python was installed correctly, by opening a command prompt and typing python. ... .
Exit the Python interpreter by entering Ctrl+Z..

How do I run Python 2 when Python 3 is installed?

So to be able to use multiple versions of Python:.
install Python 2. x (x is any version you need).
install Python 3. x (x is any version you need also you have to have one version 3. x >= 3.3).
open Command Prompt..
type py -2. x to launch Python 2. x..
type py -3. x to launch Python 3. x..

How do I open Python 2.7 in CMD?

The py Command The default Python interpreter is referenced on Windows using the command py. Using the Command Prompt, you can use the -V option to print out the version. You can also specify the version of Python you'd like to run. For Windows, you can just provide an option like -2.7 to run version 2.7.