foreman start no module named myapp
Question: I'm following the heroku quick start guide here:
<https://devcenter.heroku.com/articles/getting-started-with-python>

and I'm stuck on the foreman start part. This is what my directory looks. I'm
just running a basic web app. No frameworks or anything.

    
    
    soapbar/
        Procfile.txt
        soapbar/
            soapbar.py
        venv/
            Include/
            Lib/
            Scripts/ 
    

This is the stack trace:

    
    
    16:00:13 web.1  | started with pid 34135
    16:00:13 web.1  | 2014-03-19 16:00:13 [34135] [INFO] Starting gunicorn 18.0    
    16:00:13 web.1  | 2014-03-19 16:00:13 [34135] [INFO] Listening at: http://0.0.0.0:5000 (34135)
    16:00:13 web.1  | 2014-03-19 16:00:13 [34135] [INFO] Using worker: sync
    16:00:13 web.1  | 2014-03-19 16:00:13 [34138] [INFO] Booting worker with pid: 34138
    16:00:13 web.1  | 2014-03-19 16:00:13 [34138] [ERROR] Exception in worker process:
    16:00:13 web.1  | Traceback (most recent call last):
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    16:00:13 web.1  |     worker.init_process()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    16:00:13 web.1  |     self.wsgi = self.app.wsgi()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    16:00:13 web.1  |     self.callable = self.load()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    16:00:13 web.1  |     return self.load_wsgiapp()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    16:00:13 web.1  |     return util.import_app(self.app_uri)
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    16:00:13 web.1  |     __import__(module)
    16:00:13 web.1  | ImportError: No module named soapbar
    16:00:13 web.1  | Traceback (most recent call last):
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    16:00:13 web.1  |     worker.init_process()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    16:00:13 web.1  |     self.wsgi = self.app.wsgi()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    16:00:13 web.1  |     self.callable = self.load()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    16:00:13 web.1  |     return self.load_wsgiapp()
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    16:00:13 web.1  |     return util.import_app(self.app_uri)
    16:00:13 web.1  |   File "/Users/ranuka/soapbar/venv/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    16:00:13 web.1  |     __import__(module)
    16:00:13 web.1  | ImportError: No module named soapbar
    16:00:13 web.1  | 2014-03-19 16:00:13 [34138] [INFO] Worker exiting (pid: 34138)
    16:00:13 web.1  | 2014-03-19 16:00:13 [34135] [INFO] Shutting down: Master
    16:00:13 web.1  | 2014-03-19 16:00:13 [34135] [INFO] Reason: Worker failed to boot.
    16:00:13 web.1  | exited with code 3
    16:00:13 system | sending SIGTERM to all processes
    SIGTERM received
    

Any ideas?


Answer: Add a file named `__init__.py` to the `soapbar/` folder. Leave it empty.

> The `__init__.py` files are required to make Python treat the directories as
> containing packages; this is done to prevent directories with a common name,
> such as string, from unintentionally hiding valid modules that occur later
> on the module search path. In the simplest case, `__init__.py` can just be
> an empty file, but it can also execute initialization code for the package
> or set the `__all__` variable.

Source: <http://docs.python.org/2/tutorial/modules.html>

