Reputation: 523
I am running a basic Flask application which uses flask script, but when I move the environment from Cloud 9 to a local installation on my Mac, it stops working. I get the following error.
ImportError: No module named 'flask_script'
I am using virtualenv, and I have installed flask script in the environment, and also to tried to reinstall it as pointed out in following posts about this topic:
Python cannot find dateutil.relativedelta
Python can't find my Flask script under virtualenv
My manage.py which causes the problem looks like this:
import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from flask_script import Manager, Server
from flask.ext.migrate import MigrateCommand
from flask_app import app
manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.add_command('runserver', Server(
use_debugger = True,
use_reloader = True,
host = os.getenv('IP', '0.0.0.0'),
port = int(os.getenv('PORT', 5000))
)
)
if __name__ == "__main__":
manager.run()
When I run
pip freeze
to see what is installed, Flask_Script shows:
alembic==0.8.7
click==6.6
Flask==0.11.1
Flask-Markdown==0.3
Flask-Migrate==2.0.0
Flask-Script==2.0.5
Flask-SQLAlchemy==2.1
Flask-Uploads==0.2.1
Flask-WTF==0.12
itsdangerous==0.24
Jinja2==2.8
lxml==3.6.0
Mako==1.0.4
Markdown==2.6.6
MarkupSafe==0.23
py-bcrypt==0.4
pymongo==3.2.2
PyMySQL==0.7.6
python-docx==0.8.6
python-editor==1.0.1
python-slugify==1.2.1
requests==2.10.0
SQLAlchemy==1.0.15
Unidecode==0.4.19
Werkzeug==0.11.11
WTForms==2.1
The flask script documentation says it should be imported like this:
from flask.ext.script import Manager
As I understand it, this is an older method, which is replaced by the one I am using. But anyway, using flask.ext.script produces the same result.
Upvotes: 0
Views: 9191
Reputation: 31
Upvotes: 0
Reputation: 9088
You may have a circular dependency problem.
Have a look at this answer : https://stackoverflow.com/a/19467445/1570104 where this kind of problem is nicely explained.
Upvotes: 0