I have the following flask code, __init __ file. py:
from flask import Flask
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from flask_sqlalchemy_session import flask_scoped_session
from . import configmodule
app = Flask(__name__)
engine = create_engine(configmodule.DevelopmentConfig.SQLALCHEMY_DATABASE_URI)
session_factory = sessionmaker(bind=engine)
session = flask_scoped_session(session_factory, app)
app.config.from_object('configmodule.DevelopmentConfig')
...
The configmodule.py file is in the same directory as __init__.py above.
After starting with python 3.5.2, I get:
werkzeug.utils.ImportStringError: import_string() failed for 'configmodule.DevelopmentConfig'. Possible reasons are:
- missing __init__.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;
Debugged import:
- 'configmodule' not found.
This error is for the last line in the code snippet:
app.config.from_object('configmodule.DevelopmentConfig')
I had no problem running it with Python 2. Any idea how to make it work with Python 3? Thank.
source
share