whoisearth
whoisearth

Reputation: 4160

py2exe can't find module if in different path

I'm trying to create an exe using the following config options -

setup(name='tidalZabbix',
      version=version,
      description='python module to submit job stats to Zabbix',
      url='',
      author='Me',
      author_email='[email protected]',
      license='',
      # folders with functions
      console=[{'script': os.path.join(BASE_DIR, 'code/tidal_zabbix.py')}],
      options={
          'build': {'build_base': 'c:/tidalZabbix/build'},
          'py2exe':
              {
                  'dist_dir': 'c:/tidalZabbix',
                  'includes': ['decimal'],
              }
      }
      )

I have a separate module in the code directory called code/ZabbixSender.py

when I try to run python setup.py py2exe I get the following error -

The following modules appear to be missing
['ZabbixSender']

If I move the ZabbixSender.py to the same location as my setup.py the build works fine.

ie. if I do this:

'includes': ['decimal', 'code.ZabbixSender'],

or

'includes': ['decimal', 'ZabbixSender'],

It still doesn't find the Module.

Upvotes: 0

Views: 443

Answers (1)

whoisearth
whoisearth

Reputation: 4160

I'd like to think this is bad error reporting by p2exe.

The solution has nothing to do with my py2exe config but in the tidal_zabbix.py script being called.

This was the "incorrect" import

from ZabbixSender import ZabbixPacket, ZabbixSender

As soon as I modified it to this -

from code.ZabbixSender import ZabbixPacket, ZabbixSender

The build worked with no issues. Odd though considering running directly from python had no issues with the code.

Upvotes: 1

Related Questions