py2app ImportError with watchdog
Question: I am attempting to use py2app to bundle a small Python app that I've made in
Python 2.7 on Mac. My app uses the [Watchdog
library](http://pythonhosted.org/watchdog/), which is imported at the top of
my main file:

    
    
    from watchdog.observers import Observer
    from watchdog.events import FileSystemEventHandler
    

When running my program, these import statements work just fine, and the
program works as expected. However, after running py2app, launching the
bundled application generates the following error:

    
    
    ImportError: No module named watchdog.observers
    

At first I thought it was something to do with the `observers` module being
nested inside `watchdog`, but to test that, I added the line

    
    
    import watchdog
    

to the top of my program, and then upon running the app, got the error

    
    
    ImportError: No module named watchdog
    

so it seems that it actually can't find the `watchdog` package, for some
reason.

I tried manually adding the `watchdog` package using py2app's `--packages`
option:

    
    
    $ python setup.py py2app --packages watchdog
    

but it had no effect.

My unbundled Python program runs just fine from the command line; other
downloaded modules I've imported are giving no errors; and I have successfully
bundled a simple "Hello World!" app using py2app, so I believe my setup is
correct.

But I'm kind of out of ideas for how to get py2app to find the `watchdog`
package. Any ideas or help would be greatly appreciated.

Edit: Here is the text of my `setup.py`, as generated by py2applet. I haven't
modified it.

    
    
    from setuptools import setup
    
    APP = ['watcher.py']
    DATA_FILES = []
    OPTIONS = {'argv_emulation': True}
    
    setup(
        app=APP,
        data_files=DATA_FILES,
        options={'py2app': OPTIONS},
        setup_requires=['py2app'],
    )
    


Answer: Try manually including the desired packages in the setup.py file:

    
    
    from setuptools import setup
    
    APP = ['watcher.py']
    DATA_FILES = []
    PKGS = ['watchdog', /*whatever other packages you want to include*/]
    OPTIONS = {
        'argv_emulation': True,
        'packages' : PKGS,
    }
    
    setup(
        app=APP,
        data_files=DATA_FILES,
        options={'py2app': OPTIONS},
        setup_requires=['py2app'],
    )
    

