Alembic:AttributeError:'module'对象没有属性'suite'

时间:2017-03-16 10:07:51

标签: python sqlalchemy alembic

我正在尝试使用Alembic进行新的修订。为此,我导航到alembic目录并输入:

alembic revision -m "update my api"

输出:

Traceback (most recent call last):
  File "/home/diego/venv/bin/alembic", line 11, in <module>
sys.exit(main())
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/config.py", line 450, in main
CommandLine(prog=prog).main(argv=argv)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/config.py", line 444, in main
    self.run_cmd(cfg, options)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/config.py", line 427, in run_cmd
**dict((k, getattr(options, k)) for k in kwarg)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/command.py", line 121, in revision
revision_context.generate_scripts()
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/autogenerate/api.py", line 430, in generate_scripts
yield self._to_script(generated_revision)
   File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/autogenerate/api.py", line 366, in _to_script
**template_args)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/script/base.py", line 457, in generate_revision
heads = self.revision_map.get_revisions(head)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/script/revision.py", line 301, in get_revisions
resolved_id, branch_label = self._resolve_revision_number(id_)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/script/revision.py", line 423, in _resolve_revision_number
self._revision_map
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/util/langhelpers.py", line 241, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/script/revision.py", line 121, in _revision_map
for revision in self._generator():
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/script/base.py", line 87, in _load_revisions
script = Script._from_filename(self, vers, file_)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/script/base.py", line 729, in _from_filename
module = util.load_python_file(dir_, filename)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
  File "/home/diego/venv/local/lib/python2.7/site-packages/alembic/util/compat.py", line 81, in load_module_py
source_encoding = parse_encoding(fp)
  File "/home/diego/venv/local/lib/python2.7/site-packages/mako/util.py", line 251, in parse_encoding
parser.suite(line1.decode('ascii', 'ignore'))
AttributeError: 'module' object has no attribute 'suite'

我按照Alembic: alembic revision says Import Error的建议将PATH / to / myapi导出到$ PYTHONPATH变量,但总是遇到同样的错误。有帮助吗?谢谢

0 个答案:

没有答案