Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have python 2.7.2 installed, and I have to install python 2.6 for a specific task. And when I run now python from the command line, it runs the only version. How can I change the current installation to be run when I type python27 so I can install the older version and then run it with python26?

I have looked at the app path in the registery, but could not find how to change the name to be run. Searching google also gave me only answers on how to change the path, but not the command.

share|improve this question
up vote 2 down vote accepted

Except for some built-in comands like "dir" every command you can execute on command-line level refers in the end to an executable EXE/BAT/CMD file.

Therefore if you want to "create a new command" you can simply create a new CMD file in one the directories in the PATH list and name it as you want, e.g. python26.cmd.

The content python26.cmd would be one line like this:

@"C:\Program Files\Python26\bin\python.exe" %*
share|improve this answer
I didn't understand where the EXE/BAT/CMD should be, and what is exactly is? A folder? a registery folder? – Kahil Aug 24 '12 at 10:31
PATH is an environment variable that contains a semicolon separated list of directories that are automatically searched if an executable file if you enter a command. To see the current PATH execute cmd.exe and type echo %PATH% + Enter. – Robert Aug 24 '12 at 11:20
Sorry, but I'm kinda not getting something here - what does the PATH have to do with it? and again, how do I reach that EXE/BAT/CMD you mentioned? or should it me appended to the path? – Kahil Aug 24 '12 at 11:31
OK, in dummy mode: Create an empty text file C:\Windows\python26.cmd and add the line (with the appropriate path to the correct python.exe) into. Reperform the previous steps for C:\Windows\python27.cmd. Now you are done. It will work - you don't have to understand it. – Robert Aug 24 '12 at 12:05

I don't use python, however I do have knowledge and experience with command line; and I also know that python is command line.

Command prompt (cmd.exe, which is also the program used to execute batch file commands) runs programs/files in the system32 folder.

So by typing shutdown, cmd will search for and execute 'C:\windows\system32\shutdown.exe' (no extension provided, so it just assumes exe. I think it assumes exe, it might just run the first file that matches the query regardless of extension, can't remember). Anyway, with this in mind, if you rename python.exe (or python27.exe or whatever it's called), you should be able to change the command that you type. Of course, this only works if python places the executable directly in the system32 folder.

I hope this answers your question.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .