Reputation: 309
I have both Python 2.7 and 3.4 installed on my Windows Machine. When I type Python in CMD it defaults to Python2.7. How do I switch to 3.4?
Upvotes: 4
Views: 7620
Reputation: 209
Simply changing the name of the python.exe to anything (ex:pytoioion.exe) in your C:/Python34 or C:/Python27 will switch between the two versions. To verify, run this on your command prompt
C:Users/(your_name)>python
Upvotes: 2
Reputation: 308158
Create two batch files, python2.bat
and python3.bat
. Have each batch file add the appropriate Python directory to the path, then launch python.exe
.
E.G. Python2.bat:
@echo off
set OLDPATH=%PATH%
path C:\Python27;%PATH%
python.exe
path %OLDPATH%
Upvotes: 4
Reputation: 1108
You'll have to make changes to the PATH environmental variable. To do this, click the Start button, right click on "Computer", hit "Properties", click "Advanced System Settings" in the left sidebar. Then click the Environmental Variables button.
Under User or System variables, there will be a variable called "PATH" that includes a path to you Python installation. You can change this to the Python 3 install path.
You can also change the name of the Python 3 executable to "python3.exe", and add the directory to the path variable, separating it from other directories with a semicolon. Then you can use both 2 and 3 by calling python
and python3
respectively.
Upvotes: 3