2023. 2. 14. 12:05ㆍtrouble shoot
점프 투 플라스크 실습중 DB 설정 관련 환경 문제가 발생했다.
문제가 생긴 부분은 2-04 모델로 데이터 처리하기 에서 db 초기화 하는데 에러가 발생했다.
(myproject) c:\projects\myproject>flask db init
Traceback (most recent call last):
File "c:\users\kb01-uhshin\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\kb01-uhshin\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
...
...
File "C:\projects\myproject\pybo\__init__.py", line 7, in <module>
db = SQLAlchemy()
File "c:\users\kb01-uhshin\appdata\local\programs\python\python39\lib\site-packages\flask_sqlalchemy\__init__.py", line 758, in __init__
_include_sqlalchemy(self, query_class)
File "c:\users\kb01-uhshin\appdata\local\programs\python\python39\lib\site-packages\flask_sqlalchemy\__init__.py", line 112, in _include_sqlalchemy
for key in module.__all__:
AttributeError: module 'sqlalchemy' has no attribute '__all__'
(myproject) c:\projects\myproject>
구글링 결과 sqlalchemy 2 에서는 __all__ 지원이 삭제되었다는 내용을 찾을수 있었다.
https://github.com/pallets-eco/flask-sqlalchemy/issues/1122
AttributeError: module 'sqlalchemy' has no attribute '__all__' · Issue #1122 · pallets-eco/flask-sqlalchemy
I suspect that there is compatibility issue with SQLAlchemy 2.0. File "/.../venv/lib/python3.9/site-packages/flask_sqlalchemy/extension.py", line 982, in __getattr__ if name in mod.__all_...
github.com
점프 투 플라스크가 처음 나왔을때는 문제가 없었겠지만
시간이 지나고 pip sqlalchemy 버전이 올라가서 생긴 문제로 보인다.
sqlalchemy 버전 확인 결과 1.4, 2.0 버전을 확인할 수 있었다.
sqlalchemy 1.4 의 최신 버전인 1.4.46 모듈 설치로 db init 안되는 문제 해결~
(myproject) c:\projects\myproject>pip install --upgrade SQLAlchemy==1.4.46
Collecting SQLAlchemy==1.4.46
Downloading SQLAlchemy-1.4.46-cp39-cp39-win_amd64.whl (1.6 MB)
---------------------------------------- 1.6/1.6 MB 12.6 MB/s eta 0:00:00
Requirement already satisfied: greenlet!=0.4.17 in c:\users\kb01-uhshin\appdata\local\programs\python\python39\lib\site-packages (from SQLAlchemy==1.4.46) (2.0.2)
Installing collected packages: SQLAlchemy
Attempting uninstall: SQLAlchemy
Found existing installation: SQLAlchemy 2.0.0
Uninstalling SQLAlchemy-2.0.0:
Successfully uninstalled SQLAlchemy-2.0.0
Successfully installed SQLAlchemy-1.4.46
(myproject) c:\projects\myproject>flask db init
Creating directory c:\projects\myproject\migrations ... done
Creating directory c:\projects\myproject\migrations\versions ... done
Generating c:\projects\myproject\migrations\alembic.ini ... done
Generating c:\projects\myproject\migrations\env.py ... done
Generating c:\projects\myproject\migrations\README ... done
Generating c:\projects\myproject\migrations\script.py.mako ... done
Please edit configuration/connection/logging settings in 'c:\\projects\\myproject\\migrations\\alembic.ini' before proceeding.
'trouble shoot' 카테고리의 다른 글
Runesmith.top 가짜 광고 제거 방법 (1) | 2023.05.03 |
---|---|
[git] 여러 계정을 한 컴퓨터에서 사용시 계정 혼선 발생시 해결 (0) | 2023.02.17 |
[git] 작업전에는 git pull 하고 최신 상태에서 작업해야.. (0) | 2023.02.16 |
[CI] 빌드 장애 조치 - 윈도우에서 잠김 파일 강제 삭제 (0) | 2023.02.16 |
[Github] default branch name change (0) | 2023.02.15 |