0

如果我尝试执行from sqlalchemy.ext.declarative import *它会失败。我试过卸载软件包pip uninstall sqlalchemy 并重新安装。我已尝试从 Ubuntu 存储库(-package 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。

4

1 回答 1

1

现在它起作用了。这就是我所做的:

  • 我用 pip 卸载了 sqla
  • 手动删除剩余文件 ( rm -fr /usr/local/lib/python2.7/dist-packages/sqlalchemy)
  • 用 pip 重新安装了 sqla,现在它可以工作了。
于 2013-01-31T08:54:17.340 回答