Home  >  Q&A  >  body text

flask - heroku部署:运行命令 heroku run python manage.py deploy得到如下错误,求助?谢谢

错误日志如下,代码是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'
怪我咯怪我咯2760 days ago611

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-18 09:32:51

    It should be database migration problem. If you modify the migration file, it may be a bit difficult for you at this stage.

    Since it is the learning stage, I temporarily think that your database does not have important data, so I suggest you do this:

    1. Delete local database

    2. Delete migration folder

    3. Retry deployment

    I’ll give you an article from my blog for reference. It may not be comprehensive, but it should help you understand.

    The suggestions I put forward in the article personally think it is really important. It is recommended to delete and redeploy after reading it.

    Some experience in Flask database migration and deployment

    If you are interested, you can follow the thread and take a look at my answer on that forum. There is context for easy understanding.

    Here are some tips for you:

    1. You must learn to read error messages

    2. It is necessary to understand the migration function

    reply
    0
  • Cancelreply