运行Flask-Appbuilder 1.3.2时出现问题

时间:2015-03-16 13:47:20

标签: python flask

我已经正确安装了Flask-appbuilder软件包,并且我尝试执行fabmanager,它显示以下几行:

    (venv)lupo@Mint-VirtualBox ~ $ fabmanager
Traceback (most recent call last):
  File "/home/lupo/venv/bin/fabmanager", line 9, in <module>
    load_entry_point('Flask-AppBuilder==1.3.0', 'console_scripts', 'fabmanager')()
  File "/home/lupo/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 353, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/lupo/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 2321, in load_entry_point
    return ep.load()
  File "/home/lupo/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 2048, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/home/lupo/venv/local/lib/python2.7/site-packages/flask_appbuilder/__init__.py", line 4, in <module>
    from .models.sqla import Model, Base, SQLA
  File "/home/lupo/venv/local/lib/python2.7/site-packages/flask_appbuilder/models/sqla/__init__.py", line 4, in <module>
    from sqlalchemy.ext.declarative import as_declarative
ImportError: cannot import name as_declarative

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

an issue in Flask-AppBuilder中提到了这一点。它试图这样做:

from sqlalchemy.ext.declarative import as_declarative

但是从SQLAlchemy-0.9.9开始,as_declarative现在找到了:

from sqlalchemy.ext.declarative.api import as_declarative

这似乎是a regression in SQLAlchemy,没有理由让导入移动。

在创建Flask-AppBuilder或SQLAlchemy的新版本之前,最简单的解决方案是将SQLAlchemy降级为0.9.8:pip install sqlalchemy==0.9.8

最新版本的Flask-AppBuilder修复了这个问题。