보통은 파이썬을 공부할때 파이썬을 설치하고 파이참 등의 별도 개발툴을 설치해 사용했다.
주피터노트북은 일종의 파이썬 개발도구이다. 그런데 개발에 특화되었다기 보다는 학습에 특화된 개발도구이다.
웹 기반으로 개발환경으로 웹에서 코드를 입력하고 실행하면 그 결과를 출력해준다.
일단 설치하고 실행해보고 얘기하자.
설치는 편하게 pip install jupyter 하면 된다.
Jiseokui-MacBookPro:~ jiseokwoo$ pip3 install jupyter
Collecting jupyter
Using cached https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting ipykernel
Using cached https://files.pythonhosted.org/packages/e1/92/8fec943b5b81078399f969f00557804d884c96fcd0bc296e81a2ed4fd270/ipykernel-5.1.3-py3-none-any.whl
Collecting jupyter-console
Using cached https://files.pythonhosted.org/packages/0a/89/742fa5a80b552ffcb6a8922712697c6e6828aee7b91ee4ae2b79f00f8401/jupyter_console-6.1.0-py2.py3-none-any.whl
Collecting ipywidgets
Using cached https://files.pythonhosted.org/packages/56/a0/dbcf5881bb2f51e8db678211907f16ea0a182b232c591a6d6f276985ca95/ipywidgets-7.5.1-py2.py3-none-any.whl
Collecting qtconsole
Using cached https://files.pythonhosted.org/packages/7c/57/3528b84ffa753e2089908bbf74bb5ae60653eb7a63797b6234e88b847d67/qtconsole-4.6.0-py2.py3-none-any.whl
Collecting nbconvert
Downloading https://files.pythonhosted.org/packages/79/6c/05a569e9f703d18aacb89b7ad6075b404e8a4afde2c26b73ca77bb644b14/nbconvert-5.6.1-py2.py3-none-any.whl (455kB)
|████████████████████████████████| 460kB 360kB/s
Collecting notebook
Downloading https://files.pythonhosted.org/packages/f5/69/d2ffaf7efc20ce47469187e3a41e6e03e17b45de5a6559f4e7ab3eace5e1/notebook-6.0.2-py3-none-any.whl (9.7MB)
|████████████████████████████████| 9.7MB 1.9MB/s
Collecting ipython>=5.0.0
Downloading https://files.pythonhosted.org/packages/1c/f3/c8be38ee117d02508bb8b9158eb41ca416f442a6e8e3b3159c2f2d14ed79/ipython-7.11.1-py3-none-any.whl (777kB)
|████████████████████████████████| 778kB 3.9MB/s
Collecting tornado>=4.2
Downloading https://files.pythonhosted.org/packages/30/78/2d2823598496127b21423baffaa186b668f73cd91887fcef78b6eade136b/tornado-6.0.3.tar.gz (482kB)
|████████████████████████████████| 491kB 7.4MB/s
Collecting appnope; platform_system == "Darwin"
Downloading https://files.pythonhosted.org/packages/87/a9/7985e6a53402f294c8f0e8eff3151a83f1fb901fa92909bb3ff29b4d22af/appnope-0.1.0-py2.py3-none-any.whl
Collecting jupyter-client
Downloading https://files.pythonhosted.org/packages/13/81/fe0eee1bcf949851a120254b1f530ae1e01bdde2d3ab9710c6ff81525061/jupyter_client-5.3.4-py2.py3-none-any.whl (92kB)
|████████████████████████████████| 92kB 11.9MB/s
Collecting traitlets>=4.1.0
Downloading https://files.pythonhosted.org/packages/ca/ab/872a23e29cec3cf2594af7e857f18b687ad21039c1f9b922fac5b9b142d5/traitlets-4.3.3-py2.py3-none-any.whl (75kB)
|████████████████████████████████| 81kB 3.7MB/s
Collecting pygments
Downloading https://files.pythonhosted.org/packages/be/39/32da3184734730c0e4d3fa3b2b5872104668ad6dc1b5a73d8e477e5fe967/Pygments-2.5.2-py2.py3-none-any.whl (896kB)
|████████████████████████████████| 901kB 3.1MB/s
Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
Downloading https://files.pythonhosted.org/packages/7f/1f/e145dd467dc9b0e6f1e64232c03119498dfec497e383f1e8be9f83eaa97e/prompt_toolkit-3.0.2-py3-none-any.whl (344kB)
|████████████████████████████████| 348kB 11.9MB/s
Collecting widgetsnbextension~=3.5.0
Downloading https://files.pythonhosted.org/packages/6c/7b/7ac231c20d2d33c445eaacf8a433f4e22c60677eb9776c7c5262d7ddee2d/widgetsnbextension-3.5.1-py2.py3-none-any.whl (2.2MB)
|████████████████████████████████| 2.2MB 3.1MB/s
Collecting nbformat>=4.2.0
Downloading https://files.pythonhosted.org/packages/5d/69/87745d03d1964649ef734238b32bf08eb843a6594cb03e8bc77edc8f33e9/nbformat-5.0.3-py3-none-any.whl (169kB)
|████████████████████████████████| 174kB 5.3MB/s
Collecting ipython-genutils
Downloading https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting jupyter-core
Downloading https://files.pythonhosted.org/packages/fb/82/86437f661875e30682e99d04c13ba6c216f86f5f6ca6ef212d3ee8b6ca11/jupyter_core-4.6.1-py2.py3-none-any.whl (82kB)
|████████████████████████████████| 92kB 4.6MB/s
Collecting testpath
Downloading https://files.pythonhosted.org/packages/1b/9e/1a170feaa54f22aeb5a5d16c9015e82234275a3c8ab630b552493f9cb8a9/testpath-0.4.4-py2.py3-none-any.whl (163kB)
|████████████████████████████████| 174kB 4.7MB/s
Collecting jinja2>=2.4
Downloading https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl (125kB)
|████████████████████████████████| 133kB 5.8MB/s
Collecting entrypoints>=0.2.2
Downloading https://files.pythonhosted.org/packages/ac/c6/44694103f8c221443ee6b0041f69e2740d89a25641e62fb4f2ee568f2f9c/entrypoints-0.3-py2.py3-none-any.whl
Collecting mistune<2,>=0.8.1
Downloading https://files.pythonhosted.org/packages/09/ec/4b43dae793655b7d8a25f76119624350b4d65eb663459eb9603d7f1f0345/mistune-0.8.4-py2.py3-none-any.whl
Collecting pandocfilters>=1.4.1
Downloading https://files.pythonhosted.org/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting bleach
Downloading https://files.pythonhosted.org/packages/ab/05/27e1466475e816d3001efb6e0a85a819be17411420494a1e602c36f8299d/bleach-3.1.0-py2.py3-none-any.whl (157kB)
|████████████████████████████████| 163kB 2.4MB/s
Collecting defusedxml
Downloading https://files.pythonhosted.org/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Collecting pyzmq>=17
Downloading https://files.pythonhosted.org/packages/71/0e/ee7685d1340a4cc29fb64d164b5c5667122b2ec1a94cfc923adeef378116/pyzmq-18.1.1-cp37-cp37m-macosx_10_9_x86_64.whl (811kB)
|████████████████████████████████| 819kB 38.4MB/s
Collecting prometheus-client
Downloading https://files.pythonhosted.org/packages/b3/23/41a5a24b502d35a4ad50a5bb7202a5e1d9a0364d0c12f56db3dbf7aca76d/prometheus_client-0.7.1.tar.gz
Collecting terminado>=0.8.1
Downloading https://files.pythonhosted.org/packages/ff/96/1d9a2c23990aea8f8e0b5c3b6627d03196a73771a17a2d9860bbe9823ab6/terminado-0.8.3-py2.py3-none-any.whl
Collecting Send2Trash
Downloading https://files.pythonhosted.org/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Collecting backcall
Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz
Collecting decorator
Downloading https://files.pythonhosted.org/packages/8f/b7/f329cfdc75f3d28d12c65980e4469e2fa373f1953f5df6e370e84ea2e875/decorator-4.4.1-py2.py3-none-any.whl
Collecting jedi>=0.10
Downloading https://files.pythonhosted.org/packages/e9/97/55e575a5b49e5c3df9eb3c116c61021d7badf556c816be13bbd7baf55234/jedi-0.15.2-py2.py3-none-any.whl (1.1MB)
|████████████████████████████████| 1.1MB 2.6MB/s
Requirement already satisfied: setuptools>=18.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from ipython>=5.0.0->ipykernel->jupyter) (40.8.0)
Collecting pickleshare
Downloading https://files.pythonhosted.org/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl
Collecting pexpect; sys_platform != "win32"
Downloading https://files.pythonhosted.org/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl (58kB)
|████████████████████████████████| 61kB 10.1MB/s
Collecting python-dateutil>=2.1
Using cached https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl
Collecting six
Using cached https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Collecting wcwidth
Downloading https://files.pythonhosted.org/packages/58/b4/4850a0ccc6f567cc0ebe7060d20ffd4258b8210efadc259da62dc6ed9c65/wcwidth-0.1.8-py2.py3-none-any.whl
Collecting jsonschema!=2.5.0,>=2.4
Downloading https://files.pythonhosted.org/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl (56kB)
|████████████████████████████████| 61kB 7.6MB/s
Collecting MarkupSafe>=0.23
Downloading https://files.pythonhosted.org/packages/ce/c6/f000f1af136ef74e4a95e33785921c73595c5390403f102e9b231b065b7a/MarkupSafe-1.1.1-cp37-cp37m-macosx_10_6_intel.whl
Collecting webencodings
Downloading https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Collecting ptyprocess; os_name != "nt"
Downloading https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Collecting parso>=0.5.2
Downloading https://files.pythonhosted.org/packages/9b/b0/90353a5ece0987279837835224dead0c424833a224195683e188d384e06b/parso-0.5.2-py2.py3-none-any.whl (99kB)
|████████████████████████████████| 102kB 4.0MB/s
Collecting pyrsistent>=0.14.0
Downloading https://files.pythonhosted.org/packages/90/aa/cdcf7ef88cc0f831b6f14c8c57318824c9de9913fe8de38e46a98c069a35/pyrsistent-0.15.7.tar.gz (107kB)
|████████████████████████████████| 112kB 3.0MB/s
Collecting importlib-metadata; python_version < "3.8"
Downloading https://files.pythonhosted.org/packages/d7/31/74dcb59a601b95fce3b0334e8fc9db758f78e43075f22aeb3677dfb19f4c/importlib_metadata-1.4.0-py2.py3-none-any.whl
Collecting attrs>=17.4.0
Downloading https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl
Collecting zipp>=0.5
Downloading https://files.pythonhosted.org/packages/45/d8/f1e05f399573d2b4723dae1c1f1487dd2e7871c79ed32da741f49faaa226/zipp-2.0.0-py3-none-any.whl
Collecting more-itertools
Downloading https://files.pythonhosted.org/packages/bc/e2/3206a70758a21f9878fcf9478282bb68fbc66a5564718f9ed724c3f2bb52/more_itertools-8.1.0-py3-none-any.whl (41kB)
|████████████████████████████████| 51kB 8.1MB/s
Installing collected packages: backcall, ipython-genutils, decorator, six, traitlets, appnope, parso, jedi, pygments, pickleshare, ptyprocess, pexpect, wcwidth, prompt-toolkit, ipython, tornado, pyzmq, python-dateutil, jupyter-core, jupyter-client, ipykernel, jupyter-console, pyrsistent, more-itertools, zipp, importlib-metadata, attrs, jsonschema, nbformat, testpath, MarkupSafe, jinja2, entrypoints, mistune, pandocfilters, webencodings, bleach, defusedxml, nbconvert, prometheus-client, terminado, Send2Trash, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter
Running setup.py install for backcall ... done
Running setup.py install for tornado ... done
Running setup.py install for pyrsistent ... done
Running setup.py install for pandocfilters ... done
Running setup.py install for prometheus-client ... done
Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 appnope-0.1.0 attrs-19.3.0 backcall-0.1.0 bleach-3.1.0 decorator-4.4.1 defusedxml-0.6.0 entrypoints-0.3 importlib-metadata-1.4.0 ipykernel-5.1.3 ipython-7.11.1 ipython-genutils-0.2.0 ipywidgets-7.5.1 jedi-0.15.2 jinja2-2.10.3 jsonschema-3.2.0 jupyter-1.0.0 jupyter-client-5.3.4 jupyter-console-6.1.0 jupyter-core-4.6.1 mistune-0.8.4 more-itertools-8.1.0 nbconvert-5.6.1 nbformat-5.0.3 notebook-6.0.2 pandocfilters-1.4.2 parso-0.5.2 pexpect-4.7.0 pickleshare-0.7.5 prometheus-client-0.7.1 prompt-toolkit-3.0.2 ptyprocess-0.6.0 pygments-2.5.2 pyrsistent-0.15.7 python-dateutil-2.8.1 pyzmq-18.1.1 qtconsole-4.6.0 six-1.14.0 terminado-0.8.3 testpath-0.4.4 tornado-6.0.3 traitlets-4.3.3 wcwidth-0.1.8 webencodings-0.5.1 widgetsnbextension-3.5.1 zipp-2.0.0
Jiseokui-MacBookPro:~ jiseokwoo$
뭐 많이도 설치한다.
설치 후 구동은 아래와 같이 jupyter notebook 하면 된다.
Jiseokui-MacBookPro:~ jiseokwoo$ jupyter notebook
[I 23:23:25.326 NotebookApp] Writing notebook server cookie secret to /Users/jiseokwoo/Library/Jupyter/runtime/notebook_cookie_secret
[I 23:23:25.771 NotebookApp] Serving notebooks from local directory: /Users/jiseokwoo
[I 23:23:25.771 NotebookApp] The Jupyter Notebook is running at:
[I 23:23:25.771 NotebookApp] http://localhost:8888/?token=0439324741df4a68fe89520330e55d22c33f64540293c657
[I 23:23:25.771 NotebookApp] or http://127.0.0.1:8888/?token=0439324741df4a68fe89520330e55d22c33f64540293c657
[I 23:23:25.771 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 23:23:25.782 NotebookApp]
To access the notebook, open this file in a browser:
file:///Users/jiseokwoo/Library/Jupyter/runtime/nbserver-72561-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=0439324741df4a68fe89520330e55d22c33f64540293c657
or http://127.0.0.1:8888/?token=0439324741df4a68fe89520330e55d22c33f64540293c657
위처럼 막 뭐라뭐라 뜨고 아마 웹페이지가 하나 열릴거다. 기본 포트가 8888이므로 localhost:8888로 접근하면 접근이 가능하다. 위 메세지 친절하게 써있듯이 토큰이 포함된 url을 입력해야 정상적으로 접근이 가능하다.
http://localhost:8888/?token=0439324741df4a68fe89520330e55d22c33f64540293c657
혹시 포트를 변경하고 싶으면 아래와 같이 옵션을 주면 된다.
Jiseokui-MacBookPro:~ jiseokwoo$ jupyter notebook --port=8080
[I 23:39:03.137 NotebookApp] Serving notebooks from local directory: /Users/jiseokwoo
[I 23:39:03.137 NotebookApp] The Jupyter Notebook is running at:
[I 23:39:03.137 NotebookApp] http://localhost:8080/?token=8f86f2792fdde77ca07b451e42c9dce4855f451f2649be40
[I 23:39:03.137 NotebookApp] or http://127.0.0.1:8080/?token=8f86f2792fdde77ca07b451e42c9dce4855f451f2649be40
[I 23:39:03.137 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 23:39:03.143 NotebookApp]
To access the notebook, open this file in a browser:
file:///Users/jiseokwoo/Library/Jupyter/runtime/nbserver-77939-open.html
Or copy and paste one of these URLs:
http://localhost:8080/?token=8f86f2792fdde77ca07b451e42c9dce4855f451f2649be40
or http://127.0.0.1:8080/?token=8f86f2792fdde77ca07b451e42c9dce4855f451f2649be40
우측 상단에 보면 New가 보일거다. 새로 하나 만들어서 테스트해보자.
아래와 같은 화면을 볼 수 있는데 아마 파이썬 관련 구글링할때 많이 접했을 수 있다.
이것 저것 입력하고 Run 해보면 아래처럼 오류도 출력해주고 결과도 출력해준다.
이런식으로 코드와 실행 결과 및 기타 내용 등을 정리해 파일로 저장할 수 있도록 환경을 제공해주는게 주피터 노트북이다.
앞으로 파이썬을 이용해 머신러닝 등을 실습할 예정인데 이때 주피터 노트북을 활용해 정리해볼 예정이다.
끝.
'python' 카테고리의 다른 글
venv - Virtual Environment (0) | 2020.01.21 |
---|
댓글