在gunicorn启动期间的Python ModuleNotFoundError

时间:2017-05-11 18:03:16

标签: python flask gunicorn

我想用>> gunicorn wsgi:app开始枪炮 但我收到错误ModuleNotFoundError: No module named 'default_config。我的虚拟环境被激活了。我花了几个小时在谷歌但无法找到答案。甚至提示都非常受欢迎。

文件夹结构:

 - App
   - flask_app
   - __init__.py
   - factory.py
   - default_config.py
- venv (virtual environment)
- wsgi.py

__init__.py =>是空的

### wsgi.py ###
from flask_app.factory import create_app
app = create_app('development')

### default_config.py ###
import os

basedir = os.path.abspath(os.path.dirname(__file__))

class Config:
    SECRET_KEY = 'development key'

class DevelopmentConfig(Config):
    DEBUG = True

class ProductionConfig(Config):
    DEBUG = False

config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
    }

### factory.py ###
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from default_config import config

db = SQLAlchemy()

def create_app(config_name):
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(config[config_name])
    app.config.from_pyfile('config.py')

    db.init_app(app)
    return app

0 个答案:

没有答案