我从 Elixir 和 SQL Alchemy 开始。我已经创建了一个与 Mysql 数据库连接的 python 文件,但是一旦我使用 python 执行,我就会收到以下错误:
root@raspberrypi:/Python/mainFlask/yonkiPOPS# python yonki.py
Traceback (most recent call last):
File "yonki.py", line 1, in <module>
from elixir import metadata, Entity, Field
File "/usr/local/lib/python2.7/dist-packages/Elixir-0.7.1-py2.7.egg/elixir/__init__.py", line 29, in <module>
from elixir.entity import Entity, EntityBase, EntityMeta, EntityDescriptor, \
File "/usr/local/lib/python2.7/dist-packages/Elixir-0.7.1-py2.7.egg/elixir/entity.py", line 17, in <module>
from sqlalchemy.orm import MapperExtension, mapper, object_session, \
ImportError: cannot import name ScopedSession
我一直在寻找它,但我找不到原因。这是 yonki.py 文件:
from elixir import metadata, Entity, Field
from elixir import Unicode, UnicodeText
from elixir import *
class User(Entity):
username = Field(String(64))
metadata.bind = 'mysql://root:nomasandroid42@localhost/yonkiPOPS'
session.bind.echo = True
setup_all()
create_all()
我认为这可能是由于未安装所需的模块,但我不知道是哪一个。