1

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?

  • Yes you can. What's the problem? – glibdud Nov 21 '17 at 20:43
  • I don't know how? –  Nov 21 '17 at 20:43
  • Semi-related, look into using Anaconda. // Otherwise you can navigate to your desired python installation directory and run programs from there. Or you can provide the full path to Python when you run programs from other directories. – KDecker Nov 21 '17 at 20:45
  • Maybe [this](https://superuser.com/questions/150244/command-aliases-in-command-prompt) will help? – glibdud Nov 21 '17 at 20:45
  • I have two versions of Python on my machine and they work fine. For Python 2, I do `py -2 myfile.py`. For Python 3, I do `py -3 myfile.py`. – Kevin Nov 21 '17 at 20:45

3 Answers3

1

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

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

py -2 -m pip
xaav
  • 7,876
  • 9
  • 30
  • 47
0

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.

JGrindal
  • 793
  • 2
  • 8
  • 23
0

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.

Doğuş
  • 1,887
  • 1
  • 16
  • 24