23

I have a new 64-bit Windows machine and use python for various things and so would prefer to install 64-bit python.

However, one of my python projects creates a Windows executable that is then run on a 32-bit Windows machine (created using py2exe).

How do I use 64-bit python and py2exe to create a 32-bit executable?

If I can't do that, I guess my choices are:

  1. Use 32-bit python on all machines including mine; or

  2. Install python on the 32-bit machines and don't use py2exe.

Any advice much appreciated.

blokeley
  • 6,726
  • 9
  • 53
  • 75

1 Answers1

23

You can install both 32 and 64 bit Python on the machine and use the py2exe associated with each installation.

However, unless you actually need the extra address space of 64 bit, then you may as well just stick to 32 bit Python for compatibility. You may well find that 3rd party modules will have better availability if you are using 32 bit.

Update: Three years have passed since I wrote this. Would I stick to the advice about 64 bit Python? Probably. It is certainly true that 64 bit third party modules are easier to come by. Not least thanks to Christoph Gohlke's wonderful site.

But it is still the case the every now and again you'll find it hard to get a 64 bit version of an extension that you need. So, if your program works perfectly well in a 32 bit process, then it is perfectly sound to stick to 32 bit.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Just make sure you install the second one to a different path, of course. I have \Python26 and \Python26_32, and I call directly whichever python.exe I need. – robots.jpg Feb 08 '11 at 16:48
  • @robots.jpg You could install the 32 bit version to SysWOW64 and the 64 bit version to system32, no, that's just a silly joke!! – David Heffernan Feb 08 '11 at 16:51
  • Thanks for the advice. That's what I did on my previous machine (just used 32-bit python). If no one has a simple way of compiling 32-bit executables from 64-bit python, I'll just avoid 64-bit all together. – blokeley Feb 08 '11 at 17:14
  • 2
    @blokeley That's often a good policy. For example I have a 64 bit machine but use 32 bit versions of Python, MATLAB and Office, all because I need to interact with modules that are supplied as 32 bit only DLLs. Unless 32 bit won't get the job done, it's simpler just to stick with it. – David Heffernan Feb 08 '11 at 17:15
  • Would you say this advice is still accurate 3 years later? – JBentley Apr 03 '14 at 16:04
  • 1
    @JBentley I updated the answer. My point is that if you don't need 64 bit, what's to be gained by targetting 64 bit. – David Heffernan Apr 03 '14 at 18:17