flask - heroku部署:运行命令 heroku run python manage.py deploy得到如下错误,求助?谢谢
怪我咯
怪我咯 2017-04-18 09:30:51
0
1
634

错误日志如下,代码是copy《flask web 开发》

lanxiang@machine:~/bushu2$ heroku run python manage.py deploy
Running python manage.py deploy on ⬢ x1996... up, run.8593
INFO  [alembic.migration] Context impl PostgresqlImpl.
INFO  [alembic.migration] Will assume transactional DDL.
INFO  [alembic.migration] Running upgrade None -> f3893df0869f, init migrations
Traceback (most recent call last):
  File "manage.py", line 81, in <module>
    manager.run()
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/__init__.py", line 405, in run
    result = self.handle(sys.argv[0], sys.argv[1:])
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/__init__.py", line 384, in handle
    return handle(app, *positional_args, **kwargs)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_script/commands.py", line 145, in handle
    return self.run(*args, **kwargs)
  File "manage.py", line 71, in deploy
    upgrade()
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_migrate/__init__.py", line 98, in upgrade
    command.upgrade(config, revision, sql = sql, tag = tag)
  File "/app/.heroku/python/lib/python2.7/site-packages/alembic/command.py", line 124, in upgrade
    script.run_env()
  File "/app/.heroku/python/lib/python2.7/site-packages/alembic/script.py", line 199, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/app/.heroku/python/lib/python2.7/site-packages/alembic/util.py", line 199, in load_python_file
    module = load_module(module_id, path)
  File "/app/.heroku/python/lib/python2.7/site-packages/alembic/compat.py", line 55, in load_module
    mod = imp.load_source(module_id, path, fp)
  File "migrations/env.py", line 72, in <module>
    run_migrations_online()
  File "migrations/env.py", line 65, in run_migrations_online
    context.run_migrations()
  File "<string>", line 7, in run_migrations
  File "/app/.heroku/python/lib/python2.7/site-packages/alembic/environment.py", line 652, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/app/.heroku/python/lib/python2.7/site-packages/alembic/migration.py", line 225, in run_migrations
    change(**kw)
  File "migrations/versions/f3893df0869f_init_migrations.py", line 27, in upgrade
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
AttributeError: 'module' object has no attribute 'f'
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(1)
迷茫

应该是数据库迁移问题,如果修改迁移文件可能对你现阶段来说有点困难。

既然是学习阶段,我暂时认为你的数据库没有重要资料,那建议你这样操作:

  1. 删除本地数据库

  2. 删除迁移文件夹

  3. 重新尝试部署

给你一篇我的博客参考一下,可能有不全面的地方,但是应该能帮助你理解的。

我在文中提出的几点建议个人认为真的很重要,建议读完后再删除和重新部署

Flask 数据库迁移与部署的一些经验

如果你有兴趣,可以顺藤摸瓜看看我当时在那个论坛的回答,有上下文便于理解。

再给你一些小建议:

  1. 要学会看报错提示

  2. 是要理解迁移功能

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板