728x90
반응형
Sol 1) importlib의 reload( ) 함수 사용 (3.12 이후 imp 지원 X)
import example
import importlib
# make changes to example.py file
importlib.reload(example)
기존의 sys.path.module에 등록된 module을 reload 시킨다.
주의 해야할 것은 절대 경로에 없는 module일 경우 절대 경로에 등록을 시켜줘야한다.
Sol 2) JupyterNote Book에서 Magic Command로 reload 하는 방법
더보기
https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html
autoreload — IPython 8.14.0 documentation
Important This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7. If you are looking for an IPython version co
ipython.readthedocs.io
%load_ext autoreload
%autoreload 2
import example
# make changes to example.py file
Magic Command인 %load_ext , %autoreload를 사용한다.
%load_ext : 셀 실행
%autoreload 2 : 2는 셀이 실행될 때마다 모듈이 다시 로드 되게 한다.
이후 다시 module을 reload하면 최신 릴리스된 패키지를 노트를 종료하지 않고 사용할 수 있다.
반응형
'Python' 카테고리의 다른 글
[Version] 3.12 rc (Release Candidates) (1) - f-string (0) | 2023.10.18 |
---|---|
[JupyterNote Book] Jupytext Notebook -> Markdown (0) | 2023.09.30 |
Flask - secret_key (1) (0) | 2023.08.09 |
Flask Error : AttributeError: 'Flask' object has no attribute 'login_manager' (0) | 2023.08.08 |
[PEP 703] Making the Global Interpreter Lock Optional in CPython (0) | 2023.07.09 |