How to Use Cx_Freeze in Linux to Create a Package to Be Used in Windows

How to use cx_freeze in Windows to create a package to be used in Linux

To create a Linux executable, you need to freeze it in Linux. To create a Mac executable, you need to freeze it on a Mac. That's the way cx_Freeze works, and there isn't an option you can use to build executables for other platforms.

If you make a Windows executable, Linux users might be able to run it with Wine. But that's a workaround, and there's no guarantee that it will work.

How to use cx_Freeze to make an executable python program


  1. When you type python setup.py build, you are supposed to be in the directory with setup.py and not anywhere else. So use the command cd to get there.

  2. cx_freeze is not in your path variable so cxfreeze Julian date 2.py --target-dir dist will not work and you have to instead add it to your path (somehow) [not recommended]

Hope this helped.

P.S.
executables = [Executable("Julian date 2.py")]) takes base too. If you want a console application:
executables = [Executable("Julian date 2.py",base='None')])
Gui for windows:
executables = [Executable("Julian date 2.py",base='Win32GUI')])

And you forgot your exe options in setup(). I recommend adapting the setup.py script on cx_freeze doxs:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a
# console application).

base = "None"

setup( name = "name",
version = "0.1",
description = " ",
options = {"build_exe": build_exe_options},
executables = [Executable("file.py", base=base)])

cx_freeze PyGObject application on Linux

So the problem was not in missing libraries (as they were in the path anyway) but missing package in setup.py script. The correct setup is as follows:

from cx_Freeze import setup, Executable

setup(name="GUI Test",
description="GUITest",
version="0.1",
options={"build_exe": {"build_exe": "Bin/pygobject",
"create_shared_zip": False,
"packages": ["gi"],
}},
executables=[Executable(script="hello_pygobject.py",
targetName="hello",
appendScriptToExe=True,
)]
)


Related Topics



Leave a reply



Submit