점프 투 플라스크 / 02-4 (57-58p) 오류
이전 실습까지는 문제없이 실행되었는데 flask db migrate
명령을 실행하면 오류가 발생합니다.
실습 코드는 깃허브에서 복사했기 때문에 동일합니다.
오류 내용입니다.
(myproject) C:\projects\myproject>flask db migrate
Traceback (most recent call last):
File "C:\Users\miz\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in
_run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\miz\AppData\Local\Programs\Python\Python38\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 wrapp
ed
f(*args, **kwargs)
File "c:\venvs\myproject\lib\site-packages\flask_migrate\__init__.py", line 210, in migr
ate
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_py
thon_file
module = load_module_py(module_id, path)
File "c:\venvs\myproject\lib\site-packages\alembic\util\compat.py", line 182, in load_mo
dule_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, 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 e
ngine
return self.get_engine()
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 962, in g
et_engine
return connector.get_engine()
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 555, in g
et_engine
options = self.get_options(sa_url, echo)
File "c:\venvs\myproject\lib\site-packages\flask_sqlalchemy\__init__.py", line 570, in g
et_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 a
pply_driver_hacks
sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute
mizuflask 님 842
2021년 3월 18일 10:21 오후
1개의 답변이 있습니다. 1 / 1 Page
SQLAlchemy 가 버전 1.4로 자동 인스톨되면서 문제가 발생하는거 같네요.
다음 문서 참조하셔서 pip install SQLAlchemy==1.3.23
로 1.3.23 버전으로 SQLAlchemy를 재 설치하셔야 할 것 같습니다.
다음처럼 진행하시면 됩니다.
pip uninstall SQLAlchemy
pip install SQLAlchemy==1.3.23
박응용 님
M 2021년 3월 26일 6:16 오후