4

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?

4
  • 1
    Have you tried python3? Commented Dec 19, 2014 at 19:05
  • Have you tried to change the path? I personally prefer to have a shortcut with the every...something like python2.7.cmd and python3.4.cmd Commented Dec 19, 2014 at 19:05
  • python3 is not recognized. Commented Dec 19, 2014 at 19:11
  • 3
    Use the Python Launcher. Commented Dec 19, 2014 at 19:12

3 Answers 3

4

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%
Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

2

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.