user6514554
user6514554

Reputation:

Run python 3.6 and 2.7 on the same computer

I have python 3.6 installed on my computer with Windows 10. Python 3.6 is in the path:

C:\Users\linekm475\AppData\Local\Programs\Python\Python36-32

and I added a path so it works to just type in "python" in cmd to open python 3.6 in cmd. And the problem I have now is that I want to have python 2.7 installed too so I can use both of them. So I installed python 2.7 and it's in the path:

C:\Users\linekm475\AppData\Local\Programs\Python\Python27

Is it possible to do so when I type something like "python27" in cmd that it opens up python 2.7?

Upvotes: 1

Views: 3336

Answers (3)

xaav
xaav

Reputation: 7916

The py program is the best way to manage pythons on windows:

py -2 [commands]
py -3 [commands]

py -2 -m pip

Upvotes: 1

Doğuş
Doğuş

Reputation: 1957

1- You can use IDLE(python2.7) or IDLE(python3.6) seperately. You can use IDEs like PyCharm.

2- You can run your .py file from command promt, but you should set python2 and python3 paths to your system.

Upvotes: 0

JGrindal
JGrindal

Reputation: 813

The easiest way (assuming you're only doing this from the CLI) is to use a doskey alias. In your case it would be something like

doskey python27=C:\Users\linekm475\AppData\Local\Programs\Python\Python27

Please note that there are some serious limitations to doskey macros (most notably that it can only be used from the command line, not from a script or batch file, nor can they be used on either side of a pipe), but it will accomplish what you're trying to do.

Upvotes: 0

Related Questions