본문 바로가기
인간세상의 종말이 도래해따/오류

[python] TypeError: warn() missing 1 required keyword-only argument: 'stacklevel' 해결 완료

by 민곰 2023. 9. 26.
728x90

# 개발 환경

Windows 10

conda==4.8.3

python==3.8.0

pip==23.2.1

jupyter --version 정보

IPython : 8.8.0 ipykernel : 6.15.2 ipywidgets : 7.6.5 jupyter_client : 7.4.9 jupyter_core : 5.2.0
jupyter_server : 2.5.0 jupyterlab : 4.0.6 nbclient : 0.5.13 nbconvert : 6.4.4 nbformat : 5.9.2
notebook : 6.4.12 qtconsole : 5.4.2 traitlets : 5.10.0

 

# 현상

python 버전 변경 후 jupyter notebook 실행 시 발생한 오류.

Traceback (most recent call last):
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\notebook\traittypes.py", line 235, in _resolve_classes
    klass = self._resolve_string(klass)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\traitlets.py", line 2009, in _resolve_string
    return import_item(string)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\utils\importstring.py", line 30, in import_item
    module = __import__(package, fromlist=[obj])
ModuleNotFoundError: No module named 'jupyter_server.contents'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\username\anaconda3\envs\dev\Scripts\jupyter-notebook-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\username\AppData\Roaming\Python\Python38\site-packages\jupyter_core\application.py", line 277, in launch_instance
    return super().launch_instance(argv=argv, **kwargs)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\config\application.py", line 1044, in launch_instance
    app = cls.instance(**kwargs)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\config\configurable.py", line 555, in instance
    inst = cls(*args, **kwargs)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\traitlets.py", line 1295, in __new__
    inst.setup_instance(*args, **kwargs)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\traitlets.py", line 1338, in setup_instance
    super(HasTraits, self).setup_instance(*args, **kwargs)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\traitlets\traitlets.py", line 1314, in setup_instance
    init(self)
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\notebook\traittypes.py", line 226, in instance_init
    self._resolve_classes()
  File "C:\Users\username\anaconda3\envs\dev\lib\site-packages\notebook\traittypes.py", line 238, in _resolve_classes
    warn(f"{klass} is not importable. Is it installed?", ImportWarning)
TypeError: warn() missing 1 required keyword-only argument: 'stacklevel'

 

# 해결방안

traitlets 패키지를 5.9.0 버전으로 재설치 해주었더니 바로 해결되었다.

python 버전을 업그레이드했다가 다시 다운그레이드하는 과정에서 패키지 버전이 엉킨 듯하다.

기존 traitlets 버전은 5.10.0 버전이 설치되어 있었는데, 5.9.0 버전으로 다운그레이드 후 문제가 해결되었다.

pip uninstall traitlets
pip install traitlets==5.9.0
728x90

댓글