Brian
Brian

Reputation: 2800

Multiple Python installations in System Path

I have two Python installations on my Windows 7 64bit workstation. I have 32bit Python 2.7 and 64bit Python 2.7. Each installation is required by specific applications. I currently have only the 32bit Python installation in my system path. However, I would like to add the 64bit version to the path as well.

Right now, if I type python into my Windows command prompt it will open Python 2.7 win32. What I would like to be able to do is type python32 for the 32bit version or python64 for the 64bit version.

I realize I can rename each respective python.exe file as python32.exe and python64.exe, but this will break the hard coded paths that specific applications look for. Is it possible to some how leave each python.exe named as python.exe but give it a different command from the command prompt?

Upvotes: 2

Views: 1616

Answers (3)

seanv507
seanv507

Reputation: 1287

I use ixe013's junction approach. The one issue I have had is that enthoughts enpkg installer doesn't "read" the symbolic junction...I have lost the details, but it broke the symbolic link and then claimed the installation directory was empty...

So if you are using ixe013s approach with enthought I recommend the following when updating

delete junction : junction -d c:\python

rename c:\python.2.7.32bits to c:\python

run enpkg then go back: rename c:\python to c:\python.2.7.32bits

junction -d c:\python & junction c:\python c:\python.2.7.32bits

Upvotes: 0

ixe013
ixe013

Reputation: 10171

Here is how I handle multiple versions of Python on my system. It is even compatible with Google's python bundled in depot_tools.

  1. Download and install any version of Python in a generic folder, like the default C:\Python.
  2. Rename that folder to something specific, like c:\Python.2.7.32bits
  3. Download and install any other version you need, using the same installation folder that you rename each time.

This is to get the registry settings straight, as some applications need it.

Now download Junction and unzip it somewhere in your path. To switch from one Python to another, use this command:

junction -d c:\python & junction c:\python c:\python.2.7.32bits

In a batch file, it would look like this :

@echo off
junction -d c:\python & junction c:\python c:\python.%1
echo Now using
python -V
where python

Which you would put in your path and call with

switch-python 2.7.32bits

Upvotes: 1

Zombo
Zombo

Reputation: 1

You could add batch files for each

python32.bat

@C:\python32\python.exe %*

python64.bat

@C:\python64\python.exe %*

Upvotes: 2

Related Questions