【发布时间】:2018-08-24 04:26:29
【问题描述】:
尝试在 Heroku 上部署 Flask 应用程序,过去可以与其他应用程序完美配合,但现在当我尝试升级数据库时:
>:heroku run python manage.py db upgrade
我收到以下错误:
Traceback (most recent call last):
File "manage.py", line 121, in <module>
manager.run()
File "/app/.heroku/python/lib/python3.6/site-packages/flask_script/__init__.py", line 417, in run
result = self.handle(argv[0], argv[1:])
File "/app/.heroku/python/lib/python3.6/site-packages/flask_script/__init__.py", line 386, in handle
res = handle(*args, **config)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_migrate/__init__.py", line 259, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/app/.heroku/python/lib/python3.6/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/app/.heroku/python/lib/python3.6/site-packages/alembic/script/base.py", line 425, in run_env
util.load_python_file(self.dir, 'env.py')
File "/app/.heroku/python/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 85, in load_python_file
raise ImportError("Can't find Python file %s" % path)
ImportError: Can't find Python file migrations/env.py
文件 migrations/env.py 在我的本地机器上,在 git 存储库中:
>: git status migrations\env.py
On branch master
nothing to commit, working tree clean
我在本地使用 python 3.6.3,也尝试在 Heroku 上迁移到 python 3.6.4,因为它说不支持 3.6.3,但没有运气。
在本地,它可以正常工作,我可以迁移和升级数据库(本地和 heroku 上的 postgres)。
谢谢
【问题讨论】:
标签: python heroku flask migrate alembic