Create a 32-bit exe from python code on a 64-bit machine

I have already created a 64-bit program for Windows using cx freeze on a 64-bit machine. I am using the 64-bit premium version of Windows 7. py2exe does not work because I understand that it is not working with python 3.2.2 yet. Is there an option that I have to specify in cx freeze to compile in 32-bit rather than 64-bit.

Thanks!

+8
python
source share
3 answers

To create 32-bit executables, you need to install 32-bit versions of Python and cx_freeze.

+5
source share

In addition to the answers already indicated:

  • To compile / freeze python code for different architectures (x86 / x64), install both the x86 and x64 versions of python in your system and the corresponding options, all the necessary modules and libraries for your python installations, so both installations have the same (necessary) set of installed packages.
  • The next step is to verify that your global OS is configured correctly . The following Windows environment variables should point to the appropriate Python installation that you want to freeze, you should know in what places they should point:
    • % PATH%
    • % PYTHONHOME%
    • % PYTHONPATH%
  • Once you have configured them correctly, re-open all terminals to make sure you have loaded the new environment (go to your Windows session if necessary to update the environment correctly) and you are ready to run cx_freeze and any other python-related operations builds to get the final builds for this architecture.
  • After completing these builds, restart the process from step 2. to change the Windows environment to the next installation and build of python.

To speed up the process of changing the environment, I either performed the steps in the script or used a virtual machine.

Hope this helps.

+3
source share

All methods "produce executable code from Python code." I know that I basically create a file that associates the Python interpreter with the Python code that you want to execute inside the same file. This is not at all like compiling C code with an executable; Python is almost impossible to compile machine code in any significantly more useful way than simply pasting Python bytecode into machine code for the Python interpreter.

So, almost certainly why you cannot create a 32-bit exe from a 64-bit Python installation; there is no 32-bit interpreter for embedding in the output file.

0
source share

All Articles