My py2exe app can’t find MIBs

  1. I packed my pysnmp-based application with py2exe. When I run my app, it throws a traceback like this:

File “pysnmpentityrfc3413onelinercmdgen.pyc”, line 116, in __init__ File “pysnmpentityengine.pyc”, line 16, in __init__ File “pysnmpprotorfc3412.pyc”, line 16, in __init__ File “pysnmpsmibuilder.pyc”, line 143, in __init__ File “pysnmpsmibuilder.pyc”, line 35, in init File “pysnmpsmibuilder.pyc”, line 80, in _init ImportError: No module named mibs.instances

PySNMP claims itself to be py2exe-friendly. How to make it working?

  1. You have to list pysnmp MIB directories explicitly at your app’s so that py2exe would include them into the binary.

from distutils.core import setup
import sys

options = {}

if "py2exe" in sys.argv:
  import py2exe
  # fix executables
  options['console'] = ['']
  # add files not found my modulefinder
  options['options'] = {
    'py2exe': {
      'includes': [