Question

Attempting to build .exe using py2exe: python setup.py py2exe , receiving error:

ImportError: No module named suds

I have done some research which suggests that the module(s) have to be specifically included in setup.py. Here is my setup.py:

from distutils.core import setup
import py2exe

setup(console = [{'script':'report.py'}],
        options = {
            'py2exe': {
                'bundle_files' : 1,
                'includes' : ['suds']
            }
        })

I've tried including the package names suds.client, suds.transport.https, but the error persists. py2exe seems to have several module specific requirements found here, but I do not see any suds specific documentation.

Found some information on how py2exe finds necessary modules here. The output of

C:\Python27>python -m py2exe.mf -d /path/to/report.py
path:
    ''
    'C:\\Python27\\lib\\site-packages\\pyyaml-3.10-py2.7-win32.egg'
    'C:\\Python27\\lib\\site-packages\\progressbar-2.3-py2.7.egg'
    'C:\\Python27\\lib\\site-packages\\sqlalchemy-0.7.2-py2.7-win32.egg'
    'C:\\Python27\\lib\\site-packages\\soappy-0.12.5-py2.7.egg'
    'C:\\Python27\\lib\\site-packages\\wstools-0.3-py2.7.egg'
    'C:\\Python27\\lib\\site-packages\\fpconst-0.7.2-py2.7.egg'
    'C:\\Python27\\lib\\site-packages\\python_ntlm-1.0.1-py2.7.egg'
    'C:\\Python27\\lib\\site-packages\\django-1.3-py2.7.egg'
    'C:\\Python27\\lib\\site-packages\\pyodbc-2.1.9-py2.7-win32.egg'
    'C:\\Python27\\lib\\site-packages\\suds-0.4-py2.7.egg'
    'C:\\Windows\\system32\\python27.zip'
    'C:\\Python27\\DLLs'
    'C:\\Python27\\lib'
    'C:\\Python27\\lib\\plat-win'
    'C:\\Python27\\lib\\lib-tk'
    'C:\\Python27'
    'C:\\Python27\\lib\\site-packages'
run_script 'report.py'
    load_module '__main__' 'fp' 'report.py'
        load_module 'binascii' None None
    load_module -> Module('binascii')
    ImportError: 'No module named suds'
    ImportError: 'No module named suds'
load_module -> Module('__main__', 'report.py')

  Name                      File
  ----                      ----
m __main__                  report.py
m binascii

Missing modules:
? suds.client imported from __main__
? suds.transport.https imported from __main__

Has anyone successfully built an executable with py2exe from a script using suds packages?

OS: Windows 7 32-bit, Python: 2.7, suds: 0.4, py2exe 0.6.9

Was it helpful?

Solution

Problem is not with py2exe, I've narrowed it down to the imp.find_module call at line 498 in py2exe/mf.py. The suds module imports OK, and I can see it in sys.path, but

import imp
imp.find_module('suds', sys.path)

reports no module found.

Opening a followup question that is specific to imp module.

OTHER TIPS

Generally, importing required libraries inside of a setup script helps these kinds of problems. After the import py2exe line, try import suds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top