无法从sqlalchemy.ext.declarative导入*

时间:2013-01-30 09:28:39

标签: python sqlalchemy

如果我尝试执行from sqlalchemy.ext.declarative import *则失败。我尝试用pip uninstall sqlalchemy卸载软件包并重新安装。我已经尝试从Ubuntu存储库(python-sqlalchemy - 包)中删除该版本,但它没有安装。我有一个干净的目录,并尝试了相同的命令。还是不行。这是sqlalchemy 0.7.8和0.7.9。

这是追溯:

In [1]: from sqlalchemy.ext.declarative import *
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/nine/slask/<ipython-input-1-7f210e4ec48b> in <module>()
----> 1 from sqlalchemy.ext.declarative import *

/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/__init__.py in <module>()
   1252 """
   1253
-> 1254 from .api import declarative_base, synonym_for, comparable_using, \
   1255     instrument_declarative, ConcreteBase, AbstractConcreteBase, \
   1256     DeclarativeMeta, DeferredReflection, has_inherited_table,\

/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/api.py in <module>()
    101
    102
--> 103 class declared_attr(interfaces._MappedAttribute, property):
    104     """Mark a class-level method as representing the definition of
    105     a mapped property or special declarative member name.

AttributeError: 'module' object has no attribute '_MappedAttribute'

为了记录,我正在运行Ubuntu 12.04。

1 个答案:

答案 0 :(得分:1)

现在它有效。这就是我所做的:

  • 我用pip
  • 卸载了sqla
  • 手动删除剩余文件(rm -fr /usr/local/lib/python2.7/dist-packages/sqlalchemy
  • 用pip重新安装sqla,现在可以正常工作。