Jupyter Notebook

From EWIKI
Jump to navigation Jump to search

Useful Links:

Run Docker Server

Prepare Apache Proxy

sudo vi /etc/apache2/mods-available/proxy_html.conf

...
ProxyPass /jn/api/kernels/ ws://127.0.0.1:8888/jn/api/kernels/
ProxyPassReverse /jn/api/kernels/ http://127.0.0.1:8888/jn/api/kernels/
ProxyPass /jn/ http://127.0.0.1:8888/jn/
ProxyPassReverse /jn/ http://127.0.0.1:8888/jn/
...

see https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html

service apache2 restart 

Start docker server:

 docker run -d -p 8888:8888 --restart=always  -v /var/jupyter:/home/jovyan/work jupyter/datascience-notebook \
   start-notebook.sh --NotebookApp.base_url=/jn --NotebookApp.allow_origin='*' \
   --NotebookApp.password='sha1:fbc245cf241f:847fbf432b3bbf88fa99babe325673eabc69a284' 

see

Stand Alone

Prepare

sudo apt-get update
sudo apt-get -y upgrade
python3 -V
sudo apt-get install -y python3-pip
pip3 install notebook

Ubuntu Service (hmm?)

jupyter notebook --generate-config
jupyter notebook password
  Enter password: *************
  Verify password: *************
  [NotebookPasswordApp] Wrote hashed password to /home/mh/.jupyter/jupyter_notebook_config.json
vi /home/mh/.jupyter/jupyter_notebook_config.py
  ...
  c.NotebookApp.base_url = '/ipython/'
  ...
  c.NotebookApp.port = 8888
  ...

Configure server (deprecated: https://aichamp.wordpress.com/2017/06/13/setting-up-jupyter-notebook-server-as-service-in-ubuntu-16-04/)

sudo vi /lib/systemd/system/jupyter.service
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
# Step 1 and Step 2 details are here..
# ------------------------------------
ExecStart=/home/mh/.local/bin/jupyter-notebook --config=/home/mh/.jupyter/jupyter_notebook_config.py
User=mh
Group=mh
WorkingDirectory=/home/mh/jupyter
Restart=always
RestartSec=10
#KillMode=mixed
[Install]
WantedBy=multi-user.target
sudo systemctl enable jupyter.service
sudo systemctl daemon-reload
sudo systemctl restart jupyter.service
systemctl -a | grep jupyter
   jupyter.service   loaded    active   running   Jupyter Notebook