11

I am currently running Windows 7 Home 64-bit and am working on a program that I would like to make available for both 32-bit and 64-bit Windows operating systems. When I use cx_Freeze to turn my .py to a .exe, it only allows it to be installed on 64-bit operating systems.

Would I need to buy a 32-bit computer to convert it to a 32-bit program or are there a special set of commands I can use to make cx_Freeze create both a 32-bit and a 64-bit exe?

from cx_Freeze import *
import sys

base = None

if sys.platform == 'win32':
    base = "Win32GUI"

executables = [Executable("iNTMI.py", shortcutName = "iNTMI", shortcutDir = "DesktopFolder", base = base, icon = "C:/Program Files/iNTMI/assets/images/programIcon.ico")]

setup(
    name = "iNTMI",                                            
    options = {"build_exe": {"packages": ["tkinter", "minecraftItems", "ProgFunctions", "minecraftItems"], "include_files": ["ProgFunctions.py", "minecraftItems.py"]}},
    executables = executables
    )
jpeg
  • 2,372
  • 4
  • 18
  • 31
  • 3
    if you install 32 bit python and use only 32 bit libraries you can `freeze` it and have it work on both 32 bit and 64 bit versions of windows. the reason you get this error is you have installed the 64 bit version of python. – James Kent Jul 20 '15 at 12:50
  • @JamesKent That actually makes a lot of sense. Thank you! If I revert to a 32 bit Python, will I have to redownload all my modules again? (cx_freeze, pillow, etc)? –  Jul 20 '15 at 12:55
  • it depends on how you are installing them, if you're installing from source then usually no, but most modules that can be installed with `.exe` or `.msi` files would have to be re downloaded, but the advantage (in this case) of using 32 bit python is that one build works on both (assuming you don't need a big amount of memory or other 64bit extras) – James Kent Jul 20 '15 at 12:58
  • Certain ones I have installed by using the .whl files and others I have done with .exe/.msi. Will the .whl modules need to be replaced as well? –  Jul 20 '15 at 12:59
  • 1
    i haven't used that many `.whl` files, so i'm not certain, i think it depends on how the module is built, if it's pure python then it should be file, but if it contains C extension code then it may not. you'll probably have to just try it and see – James Kent Jul 20 '15 at 13:08
  • Yes, you'll definitely need to download new versions of any modules with compiled code, which includes cx_Freeze and pillow. If you're using pip, it will be easiest just to install all the modules you need again. – Thomas K Jul 20 '15 at 17:06

2 Answers2

5

No you do not need to buy another PC (thankfully) and no theirs no command for it either. If you want a 32bit .exe you just need an x32 bit Python installation and freeze it in the normal way and you will have a x32 executable. This will work on both x32 and x64 computers.

Since you are running x64 installation you can also create x64 .exe and have both x32 (if you get a x32 bit installation) and x64 .exe.

Xantium
  • 11,201
  • 10
  • 62
  • 89
0

You can run a virtual machine with Windows 10 32 bit and you can install Python on the machine and it works.

If you can't run a virtual machine there are lot of tutorials online.

Greenonline
  • 1,330
  • 8
  • 23
  • 31
Mat12143
  • 3
  • 3