본문 바로가기
Project/Python_Basic

Python Stopped Working on Jupyter

by sonpang 2022. 1. 14.
반응형

안녕하세요. 오늘은 Jupyter notebook 실행 후 ipynb file open 할 때 발생하는 오류에 대해 소개해드릴까 합니다.

 

1. 문제 발생

Anaconda prompt 실행 > Jupyter notebook 실행 > Chrome ipynb file 실행 > 오류 및 kernel 종료

(base) C:\Users\Administrator\Desktop\workspace>jupyter notebook
[I 11:02:38.692 NotebookApp] Serving notebooks from local directory: C:\Users\Administrator\Desktop\workspace
[I 11:02:38.693 NotebookApp] Jupyter Notebook 6.4.6 is running at:
[I 11:02:38.694 NotebookApp] http://localhost:8888/?token=bad1c22a7fa4be93411c5fc2f61e89c12c4320bc4e991040
[I 11:02:38.695 NotebookApp]  or http://127.0.0.1:8888/?token=bad1c22a7fa4be93411c5fc2f61e89c12c4320bc4e991040
[I 11:02:38.696 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:02:39.420 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/%EC%86%90%ED%95%99%EA%B7%9C/AppData/Roaming/jupyter/runtime/nbserver-12316-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=bad1c22a7fa4be93411c5fc2f61e89c12c4320bc4e991040
     or http://127.0.0.1:8888/?token=bad1c22a7fa4be93411c5fc2f61e89c12c4320bc4e991040
[I 11:02:46.444 NotebookApp] 302 GET /?token=bad1c22a7fa4be93411c5fc2f61e89c12c4320bc4e991040 (::1) 1.000000ms
[I 11:02:52.127 NotebookApp] Creating new notebook in
Bad file descriptor (bundled\zeromq\src\epoll.cpp:100)
Bad file descriptor (bundled\zeromq\src\epoll.cpp:100)

 

(base) C:\Users\Administrator\Desktop\workspace>jupyter notebook
[I 11:04:08.342 NotebookApp] Serving notebooks from local directory: C:\Users\Administrator\Desktop\workspace
[I 11:04:08.342 NotebookApp] Jupyter Notebook 6.4.6 is running at:
[I 11:04:08.343 NotebookApp] http://localhost:8888/?token=9be9cd38b4707b098dff3827d6bc172e8ae5ded4f5b19c29
[I 11:04:08.344 NotebookApp]  or http://127.0.0.1:8888/?token=9be9cd38b4707b098dff3827d6bc172e8ae5ded4f5b19c29
[I 11:04:08.345 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:04:08.998 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/%EC%86%90%ED%95%99%EA%B7%9C/AppData/Roaming/jupyter/runtime/nbserver-17128-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=9be9cd38b4707b098dff3827d6bc172e8ae5ded4f5b19c29
     or http://127.0.0.1:8888/?token=9be9cd38b4707b098dff3827d6bc172e8ae5ded4f5b19c29
[I 11:04:56.534 NotebookApp] Saving file at /test_jupyter.ipynb
[I 13:56:27.157 NotebookApp] Creating new notebook in
Bad file descriptor (bundled\zeromq\src\epoll.cpp:100)
Bad file descriptor (bundled\zeromq\src\epoll.cpp:100)

뭐 이런 결과를 토해냅니다. 마지막에 Bad file descriptor가 보이시나요?

 

 

2. 재설치 시도

Jupytor notebook을 처음 설치하고 이 문제를 겪었기 때문에 저는 당연히 재설치를 시도하였습니다.

pip install --upgrade --force-reinstall --no-cache-dir jupyter

 

중간에 이런 결과를 토해내더군요.

ERROR: Cannot uninstall 'entrypoints'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

 

뭐가 문젤까... 고민을 해보았습니다. 파일 충돌문제인가 싶었습니다. CUDA문제인가 싶었기도 했고요. Stack overflow에서 해결책을 찾았습니다. Windows 10 1909, 20H2, Python 3.6.8 3.7.9 3.8.6 3.8.7을 포함하여 이런 문제가 발생하더군요. 답변에는 역시 제가 고민한 CUDA문제 외에도 tensorflow, VC++ 라이브러리 문제로 추측하고 있었습니다.

 

 

3. 해결책

해결책은 pyzmq version downgrade였습니다.

pip uninstall pyzmq

pip install pyzmq==19.0.2

 

 

4. 분석

오류를 분석한 solution이 있던데 한번 보겠습니다. 

This error is related to your pyzmq library. It also troubles to me when I setup a brand new python environment for my new computer, recently. I just install jupyterlab (or jupyter notebook) by using pip install jupyterlab and then the problem will arise. Then, I checked the dependencies of the package, pyzmq is installed because I installed jupyterlab (or jupyter notebook), jupyterlab needs ipykernel, ipykernel needs pyzmq, and a higher version of pyzmq is installed.

 

결국 python kernel 충돌 문제가 맞긴했습니다. version downgrade로 해결할 수 있고 또 다른 방법으로는 ubuntu에서 coding environment를 구축하는 것도 있다고 하네요. 하지만 마지막에 중요한 문장이 있었는데 Anaconda에서 tensorflow를 사용하는데 문제가 발생하여 결국 사용하지 않았다는 표현이 있었습니다. 

 

관련 issue에 대한 추가적인 논의는 아래의 link가 도움이 될 것 같습다.

https://github.com/zeromq/pyzmq/issues/1505

 

Windows Python wheels: Bad address src\epoll.cpp:100 · Issue #1505 · zeromq/pyzmq

Hello, recently I set up a new python environment on a new computer as usual, I got automatically installed pyzmq==21.0.2, and I cannot use jupyter notebook, Jupyter lab, vs code at all, the python...

github.com

 

 

확실히 더 많은 것(?)을 시도하면서 느끼는 것이지만 coding environment를 설정할 때 기존에 사용하였던 environment 위에 추가한다면 tutorial을 성실하게 따라도 문제가 생길 가능성이 높다는 것입니다. OS, Interpreter, Editor가 모두 딱딱 맞물려 잘 돌아가면 좋은데 뭐 하나라도 다른 프로젝트를 하면서 사용하였던 환경을 그대로 사용하면 오류가 생길 가능성이 높다는 것입니다.(어쩌면 당연한 말일지도...) Version downgrade는 복잡한 프로그램들을 사용하지 않거나 버그가 많은 기능들을 제거하기 위해 또는 속도 향상과 쉬운 접근(사용)을 위해 종종 사용하는 방법이니 기억해두시면 좋을 것 같습니다.

반응형

'Project > Python_Basic' 카테고리의 다른 글

Python Class Attribution 추가  (6) 2022.01.26
부스트코스 코칭스터디 : AI Basic 1기  (6) 2022.01.22

댓글