°Ô½Ã¹° 1,358°Ç
   
Jupyter Notebook ¼³Ä¡, Á¢¼Ó, ȯ°æ¼³Á¤
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2020-02-26 (¼ö) 16:51 Á¶È¸ : 1325
±ÛÁÖ¼Ò :
                                
Jupyter Notebook ¼³Ä¡ ¹× Á¢¼Ó

¼ö½Ê°³ÀÇ ÇÁ·Î±×·¡¹Ö ¾ð¾î¿¡¼­ ´ëÈ­Çü ÄÄÇ»ÆÃÀ» À§ÇÑ °ø°³ ¼Ò½º ¼ÒÇÁÆ®¿þ¾î, °ø°³ Ç¥ÁØ ¹× ¼­ºñ½º¸¦ °³¹ßÇϱâ À§ÇØ ¸¸µé¾îÁø ºñ¿µ¸® ´Üü Project Jupyter¿¡¼­ ¸¸µç ProductÁß ÇϳªÀÔ´Ï´Ù. 

¸Ó½Å·¯´×°ú Data Science ºÐ¾ß, °úÇко߿¡¼­ PythonÀ» ¼Õ½±°Ô ¾µ¼ö ÀÖµµ·Ï ¸¸µé¾îÁø Åø·Î½á ½Ç½Ã°£À¸·Î ÀÎÅÍ·ºÆ¼ºêÇÏ°Ô µ¥ÀÌÅ͸¦ º¸¿©Áشٴ ÀåÁ¡ÀÌ ÀÖ½À´Ï´Ù.

ÆÄÀ̼±Äڵ带 ¶óÀκ°·Î ½ÇÇàÇÏ°í ±×¿¡ µû¸¥ íƮ, À̹ÌÁö, ºñµð¿ÀµîÀ» ½Ã°¢ÀûÀ¸·Î º¸¿©ÁÖ°í, º¹ÀâÇÑ °ø½ÄµîÀ» °£°áÇÏ°Ô ¼öÇÐåó·³ º¸¿©Áֱ⵵Çϸ砰³¹ßIDE¿¡ ´É¼÷ÇÏÁö ¾ÊÀº »ç¶÷µé¿¡°Ô º¹ÀâÇÑ ÆÄÀ̽ãÄڵ带 ÄÚµå ºí·°º°·Î ½ÇÇà ¹× ¼³¸íÇÏ¸ç °øÀ¯ÇÒ¼ö ÀÖ´Â ±â´ÉµéÀÌ ÀÖ½À´Ï´Ù. 


iwinv °¡»ó¼­¹ö
ȯ°æ : Ubuntu 18.04 LTS

Pip and python ¼³Ä¡
# apt-get -y install python3 python-pip python-dev

# python --version
Python 2.7.17

# pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

# pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 612kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-20.0.2


jupyter ¼³Ä¡
# pip install jupyter

# jupyter --version
jupyter core     : 4.6.3
jupyter-notebook : 5.7.8
qtconsole        : 4.6.0
ipython          : 5.9.0
ipykernel        : 4.10.1
jupyter client   : 5.3.4
jupyter lab      : not installed
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 4.4.0
traitlets        : 4.3.3


root ±ÇÇÑ¿¡¼­ ÀÛ¾÷½Ã¿¡´Â ¾Æ·¡Ã³·³ ¸Þ¼¼Áö°¡ Ãâ·ÂµÇ¸ç --allow-root ¿É¼ÇÃß°¡
# jupyter notebook
[I 15:55:18.670 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[C 15:55:18.848 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.

# jupyter notebook --allow-root


¼­ºñ½º ÇÁ·Î¼¼¼­°¡ foreground ÇüÅ·Π½ÇÇàµÇ¸ç ¼¼¼ÇÀÌ Á¾·áµÇÁö ¾Ê°Ô backgroud  "&" ȤÀº nohup ¿É¼ÇµîÀ» ÁÖ¾î ½ÇÇàÇÑ´Ù.
# jupyter notebook --allow-root &


Jupyter Á¢¼Ó 
±âº»Æ÷Æ®´Â 8888 ÀÌ¸ç ·ÎÄÃÀÌ ¾Æ´Ñ ¿ø°Ý¿¡¼­ À¥À» ÅëÇØ Á¢¼ÓÇÏ·Á¸é ¾Æ·¡¿Í °°Àº ¹æ¹ýÀ¸·Î °¡´ÉÇÏ´Ù.
# netstat -anlp |grep 8888
tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      19558/python   


1.  --ip ¿É¼ÇÈ°¿ë
# ifconfig ens3
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.1.0.7  netmask 255.255.0.0  broadcast 10.1.255.255
        inet6 fe80::f816:3eff:fe47:2c7a  prefixlen 64  scopeid 0x20<link>
        ether fa:16:3e:47:2c:7a  txqueuelen 1000  (Ethernet)
        RX packets 27858  bytes 150481517 (150.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16641  bytes 2275966 (2.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# jupyter notebook --allow-root --ip 10.1.0.7 &

# netstat -anlp |grep 8888
tcp        0      0 10.1.0.7:8888           0.0.0.0:*               LISTEN      19747/python      



2. ȯ°æ¼³Á¤ config ÆÄÀÏ ¼öÁ¤
# jupyter notebook --allow-root --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py

# vim /root/.jupyter/jupyter_notebook_config.py
..........................................
## The IP address the notebook server will listen on.

c.NotebookApp.ip = '10.1.0.7'
..........................................
# jupyter notebook --allow-root --config /root/.jupyter/jupyter_notebook_config.py &




¿ø°Ý¿¡¼­ Á¢¼ÓÇÒ¼ö Àִ ȯ°æ¼³Á¤Àº ³¡ÀÌ´Ù.
À¥ ºê¶ó¿ìÀú¸¦ ÅëÇØ Á¢±ÙÇÏ¸é µÈ´Ù.
http://<IPADDRESS>:8888

Password or token â¿¡´Â Jupyter ¼­¹ö¸¦ ½ÇÇà½Ãų¶§ ³ª¿À´Â token °ªÀ» ³Ö¾îÁÖ¸é µÈ´Ù.




ÅäÅ«À» ÀÔ·ÂÇÏ°í Á¢±ÙÇÏ¸é ¾Æ·¡¿Í °°Àº âÀÌ ³ª¿Â´Ù.
ȯ°æ¼³Á¤ÆÄÀÏÀ» ÅëÇØ ¼­ºñ½º¸¦ ±¸µ¿½ÃÄ×´Ù¸é jupyter_notebook_config.py µîÀÌ Files ¸ñ·Ï¿¡ ¿Ã¶ó¿ÍÀÖ´Ù.


python3 Ãß°¡
  - python 3.x = pip3
  - python 2.7 = pip 

# apt install python3-pip python3-dev

# python3 --version
Python 3.6.9

# pip3 install --upgrade pip
# pip3 install virtualenv
# pip install jupyter




ºÎÆýà ÀÚµ¿½ÇÇàÀ» À§ÇØ service µî·Ï
jupyter.service ÆÄÀÏ»ý¼º 

# vim /etc/systemd/system/jupyter.service 
 <username> »ç¿ëÀÚ¸í ¹× °æ·Î´Â º»ÀÎÀÇ È¯°æ¿¡ ¸ÂÃç¼­...
[Unit]
Description=Jupyter Notebook Server 

[Service] 
Type=simple 
PIDFile=/run/jupyter.pid 
User=<username> 
ExecStart=/home/<username>/.local/bin/jupyter-notebook 
WorkingDirectory=/your/working/dir

[Install]
WantedBy=multi-user.target

# systemctl daemon-reload 
# systemctl enable jupyter.service 
# systemctl start jupyter.service
systemctl status jupyter.service



# jupyter-notebook --h
usage: jupyter-notebook [-h] [--log-level NOTEBOOKAPP.LOG_LEVEL]
                        [--config NOTEBOOKAPP.CONFIG_FILE]
                        [--ip NOTEBOOKAPP.IP] [--port NOTEBOOKAPP.PORT]
                        [--port-retries NOTEBOOKAPP.PORT_RETRIES]
                        [--transport KERNELMANAGER.TRANSPORT]
                        [--keyfile NOTEBOOKAPP.KEYFILE]
                        [--certfile NOTEBOOKAPP.CERTFILE]
                        [--client-ca NOTEBOOKAPP.CLIENT_CA]
                        [--notebook-dir NOTEBOOKAPP.NOTEBOOK_DIR]
                        [--browser NOTEBOOKAPP.BROWSER]
                        [--pylab [NOTEBOOKAPP.PYLAB]]
                        [--gateway-url GATEWAYCLIENT.URL] [--debug]
                        [--generate-config] [-y] [--no-browser] [--no-mathjax]
                        [--allow-root] [--script] [--no-script]

optional arguments:
  -h, --help            show this help message and exit
  --log-level NOTEBOOKAPP.LOG_LEVEL
  --config NOTEBOOKAPP.CONFIG_FILE
  --ip NOTEBOOKAPP.IP
  --port NOTEBOOKAPP.PORT
  --port-retries NOTEBOOKAPP.PORT_RETRIES
  --transport KERNELMANAGER.TRANSPORT
  --keyfile NOTEBOOKAPP.KEYFILE
  --certfile NOTEBOOKAPP.CERTFILE
  --client-ca NOTEBOOKAPP.CLIENT_CA
  --notebook-dir NOTEBOOKAPP.NOTEBOOK_DIR
  --browser NOTEBOOKAPP.BROWSER
  --pylab [NOTEBOOKAPP.PYLAB]
  --gateway-url GATEWAYCLIENT.URL
  --debug
  --generate-config
  -y, --y
  --no-browser
  --no-mathjax
  --allow-root
  --script
  --no-script



À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.