2-04 오류
flask db migrate 실행하면 오류가 나는데 어떻게 해야하나요?
</>(myproject) c:\projects\myproject>flask db migrate
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\venvs\myproject\Scripts\flask.exe\__main__.py", line 7, in <module>
File "c:\venvs\myproject\lib\site-packages\flask\cli.py", line 967, in main
cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
File "c:\venvs\myproject\lib\site-packages\flask\cli.py", line 586, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\venvs\myproject\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\venvs\myproject\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\venvs\myproject\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\venvs\myproject\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\flask\cli.py", line 426, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\flask_migrate\cli.py", line 91, in migrate
_migrate(directory, message, sql, head, splice, branch_label, version_path,
File "c:\venvs\myproject\lib\site-packages\flask_migrate\__init__.py", line 96, in wrapped
f(*args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\flask_migrate\__init__.py", line 210, in migrate
command.revision(config, message, autogenerate=True, sql=sql,
File "c:\venvs\myproject\lib\site-packages\alembic\command.py", line 212, in revision
script_directory.run_env()
File "c:\venvs\myproject\lib\site-packages\alembic\script\base.py", line 490, in run_env
util.load_python_file(self.dir, "env.py")
File "c:\venvs\myproject\lib\site-packages\alembic\util\pyfiles.py", line 97, in load_python_file
module = load_module_py(module_id, path)
File "c:\venvs\myproject\lib\site-packages\alembic\util\compat.py", line 182, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "migrations\env.py", line 25, in <module>
str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%'))
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 943, in engine
return self.get_engine()
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 962, in get_engine
return connector.get_engine()
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 555, in get_engine
options = self.get_options(sa_url, echo)
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 570, in get_options
self._sa.apply_driver_hacks(self._app, sa_url, options)
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 914, in apply_driver_hacks
sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute</>
loveholic.g 님 652
M 2021년 3월 18일 7:27 오후
2개의 답변이 있습니다. 1 / 1 Page
SQLAlchemy 가 버전 1.4로 자동 인스톨되면서 문제가 발생하는거 같네요.
다음 문서 참조하셔서 pip install SQLAlchemy==1.3.23
로 1.3.23 버전으로 SQLAlchemy를 재 설치하셔야 할 것 같습니다.
박응용 님
2021년 3월 18일 10:59 오후