Question

I'm trying to produce a small .exe using cx_freeze. Earlier I had trouble with the build process in that it would not find certain self-created modules. I have now resolved that issue and I am no longer seeing those self-made modules in the Missing modules output after running python setup.py bdist_msi.

Instead, now after attempting to run the 'main.exe` that is produced I see:

ImportError No module named 'test'

My project structure is:

PROJECT
|
SRC
   |
   setup.py
   main.py
   test.py
   service.py

The setup.py is as follows:

import sys
from cx_Freeze import setup, Executable

base = None

if sys.platform == "Win32":
    base = "Win32GUI"

includes = ["test", "service"] #discovered that self made modules, even in the same directory, had to be added here to not appear in the 'Missing modules'
excludes = []
packages = []
path = []

setup(
      name = "a thing", 
      version = "1.0",
      description = "a things description",
      author = "author",
      author_email = "authors email",
      url = "authors url",
      options = {"build_exe": {"includes": includes,
                               "excludes": excludes,
                               "packages": packages,
                               "path": path}
                 },
      executables = [Executable("main.py", base = base)]
  )
Was it helpful?

Solution

generally you dont need to do any special treatment for your own modules.

i tried the following and for me it worked fine: main.py:

from test import *

if __name__ == "__main__":
    mA=A()
    mA.b();

test.py:

class A:
    def b(self):
        print("test")

setup.py:

like yours  (without service.py)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top