how to msi install Python to non-default target dir?

Zachary Ware zachary.ware+pylist at
Wed Jul 16 18:45:34 CEST 2014

On Wed, Jul 16, 2014 at 9:33 AM, Albert-Jan Roskam <fomcl at> wrote:
> From: Zachary Ware <zachary.ware+pylist at>
>> Also, 'set' doesn't require quotes
>> around a value with spaces, and you're also quoting %PYTHONDIR% when
>> you use it in the msiexec command, so you're actually double-quoting
>> the dir name (which could also be the issue).
> That was it, thank you!!

Glad I could help :)

>> And, not necessarily an
>> issue that would prevent installing, but you may want to make sure
>> you're in the correctly-bitted Program Files directory if you're on
>> 64-bit Windows (%PROGRAMFILES% for 64-bit, %PROGRAMFILES(x86)% for
>> 32-bit; %PROGRAMFILES(x86)% will not be defined on 32-bit Windows or
>> in a 32-bit process on 64-bit Windows).
> Good point. The easiest solution would be to write one .bat for 32bit and one for 64bit.

You could also do something like (untested, but I've used similar in
the Doc/make.bat script):

   if DEFINED ProgramFiles(x86) set 64bitext=.amd64
   set PYTHONDIR=%ProgramFiles%\Python27
   set PYTHONMSI=python-2.7.3%64bitext%.msi

That's for 64-bit Python on 64-bit Windows, 32-bit Python on 32-bit
Windows.  Or:

   if DEFINED ProgramFiles(x86) set PgrmFls=%ProgramFiles(x86)%
   if NOT DEFINED ProgramFiles(x86) set PgrmFls=%ProgramFiles%
   set PYTHONDIR=%PgrmFls%\Python27
   msiexec /i python-2.7.3.msi TARGETDIR="%PYTHONDIR%" /qb

for 32-bit Python on either platform.


More information about the Python-list mailing list