tiangolo / meinheld-gunicorn-flask-docker

Docker image with Meinheld and Gunicorn for Flask applications in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModuleNotFoundError: No module named 'apscheduler'

yacitus opened this issue · comments

I've tried multiple versions of FROM tiangolo/meinheld-gunicorn-flask:python3.6, including (also) FROM tiangolo/meinheld-gunicorn-flask:python3.7 and FROM tiangolo/meinheld-gunicorn-flask:python3.6-alpine3.8 and each time I get the following after running docker run -d -p 80:80 -e MODULE_NAME="flask_app.main" myimage:

Running script /app/prestart.sh
Running inside /app/prestart.sh, you could add migrations to this file, e.g.:

#! /usr/bin/env bash

# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head

[2019-09-03 21:18:57 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2019-09-03 21:18:57 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
[2019-09-03 21:18:57 +0000] [1] [INFO] Using worker: egg:meinheld#gunicorn_worker
[2019-09-03 21:18:57 +0000] [8] [INFO] Booting worker with pid: 8
[2019-09-03 21:18:57 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
  File "/app/app/main.py", line 4, in <module>
    from apscheduler.schedulers.background import BackgroundScheduler
ModuleNotFoundError: No module named 'apscheduler'
[2019-09-03 21:18:57 +0000] [8] [INFO] Worker exiting (pid: 8)
{"loglevel": "info", "workers": 8, "bind": "0.0.0.0:80", "workers_per_core": 2.0, "host": "0.0.0.0", "port": "80"}
[2019-09-03 21:18:57 +0000] [1] [INFO] Shutting down: Master
[2019-09-03 21:18:57 +0000] [1] [INFO] Reason: Worker failed to boot.
{"loglevel": "info", "workers": 8, "bind": "0.0.0.0:80", "workers_per_core": 2.0, "host": "0.0.0.0", "port": "80"}

I even tried renaming "flask_app" to "app" and dropping the -e, but I get the "No module named 'apscheduler'" error each time.

Oops. I forgot about this in my main.py: from apscheduler.schedulers.background import BackgroundScheduler

I'll try adding pip install apscheduler to my Dockerfile.

Silly of me to forget to install all the extra packages I installed into my virtualenv.

Thanks for reporting back and closing the issue 👍