braindump_
  • Home
  • Categories
  • Tags
  • Archives

Managing multiple python installations on Windows

Problem

So sometimes, it might be good idea to keep several sandboxed python installations. Here are some examples where such a scenario may occur:

  • My default python installation is 2.7
  • I want to keep my EPD distribution clean
  • The Ogre3D bindings are only available for Python2.6 at the moment
  • What about using python3 alongside everything else?

A Solution

The idea here is to create a command prompt shortcut for every concurrent python installation.

First, you need a .bat file that will set various environment variables. Here is an example file, targetted at my EPD installation, which is installed in C:\Python26_EPD622:

Copy this, and change the PYTHON_ROOT variable to the root folder of the python installation you're configuring. Put the file anywhere you want to.

Next, we will create a shortcut to a windows command prompt that will automatically call that script, and setup your environmnent.

Locate the folder containing the original Command Prompt shortcut. On Windows Vista/7, it should be in: C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories.

Copy it, and rename it, for example to Python26 (EPD 6.2) Command Prompt. Rigth click on it, select Properties. This should appear:

before
before

Change the target to: %comspec% /k ""c:\path\to\epd62.bat"" and click OK. Notice the two pairs of double quotes.

after
after

You can now move this shortcut wherever you see fit. You can keep it in the start menu, create a special start menu folder for all your python prompts, move it to the quicklaunch bar, and so on.

Once this is done, you can now:

  • Launch a (i)python shell
  • Install packages with easy_install or pip
  • Launch any binary third party tool shipped with your python distribution
success
success

Repeat for every python installation.

Final note

This is not a mean to register several python distribution with your IDE. Any decent python IDE, such as Pydev for eclipse or PyCharm let you register several python interpreters.


Published

Sep 12, 2010

Last Updated

Jun 20, 2015

Category

Python

Tags

  • python 7
  • windows 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor