0

I want to install Python 2.7 in two places at once on my Windows machine. For example, one in c:\python27 and another in c:\myproduct\python27. The official installer refuses to let me do this. If there is already an installation when I run the installer, it prompts me and asks if I want to Change, Repair or Remove the existing installation.

The TARGETDIR trick mentioned elsewhere on Stackoverflow doesn't work either - I get the same result if I type the following into a cmd window:

msiexec /i python-2.7.8.msi TARGETDIR=c:\myproduct\python27

So, is there anyway to install Python 2.7 twice on my Windows machine?

Reasons I want to do this are:

  1. My product requires a 32-bit version of Python 2.7 to be installed because it uses ctypes to load a 32-bit DLL. If the user already has a 64-bit version of 2.7 installed, I don't think it is safe to install the 32-bit version over the top.
  2. Relying on the users pre-installed Python 2.7 is bad because they might uninstall it later. That would stop my product from working.
  3. It reduces the complexity of testing my product if I can make its installer always install a known version of Python. I can rely on it being in a known state.
  4. I'd like to add the pyreadline module to the Python install that is part of my product. I suspect most users would rather that I did not mess around with their Python install.
  5. When a user uninstalls my product, the Python it installed should also be removed. If I installed Python in the standard place the user might come to use it for other purposes and be surprised when it goes missing when they uninstall my product.
Andrew Bainbridge
  • 4,651
  • 3
  • 35
  • 50
  • 1
    You can try using virtualenv on [Windows](http://virtualenv.readthedocs.org/en/latest/virtualenv.html) – Anshul Goyal Nov 06 '14 at 14:56
  • 1
    Numbers 4 and 5 in your list can be addressed by using virtualenv to create a local copy of the interpreter, but you would still need a suitable interpreter already on the system. – Duncan Nov 06 '14 at 14:56
  • You can get a pre-built version of virtualenv for Windows from [here](http://www.lfd.uci.edu/~gohlke/pythonlibs/#virtualenv). – martineau Nov 06 '14 at 15:10

1 Answers1

0

It appears that you should be able to install the 32 bit version of Python 2.7 in another folder when the 64-bit version is already installed. See How do I install Python 2.7.3 32 bit and 64 bit on Windows side by side for a description. However it may be tricky to automate this, you might have to get users to install it themselves.

I would suggest you ask your users to install Python 2.7 32-bit, and give them instructions on how to do it if they already have a conflicting 64-bit version. Then in your installation you:

  1. Ensure that virtualenv is installed (and install it if it is not).
  2. Create a virtualenv in your application folder.

That addresses everything except the second item on your list and I think you simply have to accept that no matter what you do, if someone removes a component that you need your application will fail. If they do that they can use the 'repair' option on your installer from which you can either reinstall the missing Python or tell them that's what they need to do.

To install virtualenv I would first install pip (see https://pip.pypa.io/en/latest/installing.html for instructions, you need to download get_pip.py and run it with the Python 2.7 interpreter), then just run pip install virtualenv.

Community
  • 1
  • 1
Duncan
  • 92,073
  • 11
  • 122
  • 156