0

I am trying to convert a Python project to exe using py2exe. My project directory structure is:

project/
    __init__.py
    main.py
    src/
        __init__.py
        interface/
            __init__.py
            window.py
            secondary.py
    ui/
        settings.ui
    icons/
        project.png

In main.py, there is import src.interface.window as win statement, when I try to create exe using py2exe, it shows an error message: The following modules appear to be missing: [src.interface.window]. I don't know how to include all the modules in setup script so that distutils can recognize them.

My setup script:

import py2exe
from distutils.core import setup

setup(packages=['project.src.interface'],
      package_data={'project': ['ui/*', 'icons/*']},
      windows=[{'script': 'project/main.py'}],
      options={'py2exe': {'skip_archive': True, 'includes': ['sip', 'pgmagick', 'PyQt4.QtGui', 'PyQt4.QtCore']}})
qurban
  • 3,885
  • 24
  • 36

1 Answers1

1

Try this (assuming the setup file is in the project/ directory):

setup(name='project'
      packages=['project', 'project.interface'],
      package_dir={'project': 'src', 'project.interface': 'src/interface'},
      package_data={'project': ['ui/*', 'icons/*']},
      windows=[{'script': 'project/main.py'}],
      options={'py2exe': {'skip_archive': True, 'includes': ['sip', 'pgmagick', 'PyQt4.QtGui', 'PyQt4.QtCore']}})

and then:

import project.interface.window

(Note: I did not test it)

Valentin Lorentz
  • 9,556
  • 6
  • 47
  • 69