기본적으로 jupyter notebook 을 쓰고 있었다면 jupyter lab을 설치하기만 해도 설정을 다 가져오는 것 같음. (원격 서버 설정 등)
jupyter lab 사용시 주로 matplotlib 으로 interactive widget을 만들거나 복잡한 시각화를 하게 되는데..
%matplotlib widget을 쓰려니 오류가 난다면 아래 사항을 체크해보자.
1. 12 이상의 node.js 설치
https://jupyterlab.readthedocs.io/en/stable/user/extensions.html
Extensions — JupyterLab 3.2.0b0 documentation
Once you have found a source extension that you think is interesting, install it by clicking the “Install” button of the extension list entry. Danger Installing an extension allows it to execute arbitrary code on the server, kernel, and in the client
jupyterlab.readthedocs.io
위 내용에 따르면
conda install -c conda-forge nodejs
를 해주면 된다. 이때, 그냥 깔면 구구구버전인 6.13.1 버전이 깔리므로 최신 jupyter lab과 호환이 안 될 수 있다.
https://stackoverflow.com/questions/62325068/cannot-install-latest-nodejs-using-conda-on-mac
Cannot install latest nodejs using conda on Mac
When I run conda search -c conda-forge nodejs, I get: # Name Version Build Channel ... nodejs 14.2.0 h2c41780_1 conda-forge nodejs ...
stackoverflow.com
위 내용에 따라 아래 커맨드로 설치해주자.
conda install nodejs -c conda-forge --repodata-fn=repodata.json
버전 12 이상인지 확인해주자. 참고로 컴퓨터 사양에 따라 버젼 12이상이 아니어도 될 수도 있다.
2. ipympl 설치
https://anaconda.org/conda-forge/ipympl
Ipympl :: Anaconda.org
anaconda.org
conda install -c conda-forge ipympl
3. 버젼 정보 확인
https://github.com/matplotlib/ipympl#use-in-jupyterlab
GitHub - matplotlib/ipympl: Matplotlib Jupyter Integration
Matplotlib Jupyter Integration. Contribute to matplotlib/ipympl development by creating an account on GitHub.
github.com
위 링크로 들어가서 Versions lookup table을 확인해보자.
내 개발환경의 ipympl, jupyterlab, matplotlib 정보를 확인한다. 아래 커맨드로 각각 conda 와 pip 패키지 버젼을 확인할 수 있다.
conda list ipympl
pip show ipympl
3개 버젼을 체크해서 lookup table 상 한 행에 잘 들어가는지 확인하고 아니면 버젼을 조정해준다.
pip install matplotlib==3.3.1
pip는 이런식으로, conda는 구글에 'conda install matplotlib 3.3.1'이라고 치면 적당한 conda-forge 커맨드를 찾을 수 있다.
이렇게 버젼을 잘 맞춰준 뒤, 해당하는 jupyter-matplotlib 버전 정보를 기억해둔다.
4. jupyter labextension 설치
커맨드 창에 jupyter lab을 쳐서 주피터 서버를 실행시킨뒤, extention 탭을 클릭하여 extension을 활성화한다.
이후 jupyterlab-manager와 jupyter-matplotlib을 설치한다. (GUI로도 가능. 단, 버전 지정은 불가)
jupyter labextension install jupyterlab-manager
jupyter labextension enable jupyterlab-manager
이 때 @ 사인을 이용해주면 pip install package==1.2.0 과 같이 버젼 정보를 특정하여 다운로드 할 수 있다.
npm 기반이라 @ 사인을 이용한다. 아까 룩업테이블에서 확인한 버젼을 입력해준다.
jupyter labextension install jupyterlab-matplotlib@0.9.0
jupyter labextension enable jupyterlab-matplotlib
다운로드가 완료 되었으면, 아래 커맨드로 원하는 extension 버젼이 잘 다운로드 되었는지 확인한 후 빌드한다.
jupyter labextention list
jupyter lab build
이제 jupyter notebook에서는 사용하기 번거롭던 interactive widget을 자유롭게 사용할 수 있다.