我正在通过烧瓶教程,试图运行一个脚本来创建数据库,而不是通过命令行执行。它使用SQLAlchemy-migrate包,但是当我尝试运行脚本时,它会给出一个ImportError。Flask - ImportError:没有名为migrate.versioning的模块
这是终端输出:
Sean:app seanpatterson$ python ./db_create.py
Traceback (most recent call last):
File "./db_create.py", line 2, in <module>
from migrate.versioning import api
ImportError: No module named migrate.versioning
这是db_create.py脚本:
#!flask/bin/python
from migrate.versioning import api
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from app import db
import os.path
db.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
这是在配置文件中所引用:
#!/usr/bin/env python
import os
basedir = os.path.abspath(os.path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
本申请是与虚拟环境一起运行。这是涉及到它,我已经在环境中安装的模块:
sqlalchemy_migrate-0.7.2-py2.7.egg-信息
任何帮助表示赞赏
是的,你是完全正确的,我也有安装在虚拟环境中的所有沿模块。卫生署! –