Recently, I'm reading a statistics book while studying data science, but it can be difficult to imagine just reading a book, so I wanted to do it while writing code at hand using Jupyter Notebook. thought. When writing code with Jupyter Notebook, I wanted to be able to use vim because the tension would not rise unless I could use vim key bindings, but I was a little addicted to it, so I summarized the method.
version | |
---|---|
Mac | 10.15.3 |
Docker | 19.03.4 |
docker-compose | 1.24.1 |
Launch a Jupyter Notebook with vim keybindings using Dockerfile and docker-compose.
$ mkdir notebooks
Dockerfile
FROM jupyter/minimal-notebook:latest
USER root
RUN pip install jupyter_contrib_nbextensions && \
jupyter contrib nbextension install --user && \
git clone https://github.com/lambdalisue/jupyter-vim-binding /home/jovyan/.local/share/jupyter/nbextensions/vim_binding && \
jupyter nbextension enable vim_binding/vim_binding
EXPOSE 10000
CMD ["bash"]
jupyter-vim-binding
repository must match the path of the command jupyter. (You can check it with the jupyter --path
command)docker-compose.yml
version: '3'
services:
data-science:
restart: always
build: .
container_name: 'data-science'
ports:
- "10000:10000"
working_dir: '/root/'
tty: true
volumes:
- ./notebooks:/root/notebooks/
$ docker-compose up -d --build
$ docker-compose exec data-science bash
/root# jupyter notebook --port 10000 --allow-root
Access the displayed http://127.0.0.1:10000/?token=xxxxxxxxxxxxxxxx
.
By default, disable
is checked in the extension settings, so uncheck it to enable it.
Now you can use vim on your notebook
The method of making vim key bindings available in Jupyter Notebook was quite organized, but I was addicted to it except when I tried various things, so I tried to summarize it myself. Now you can write a comfortable Notebook! (However, this time I made all users root, so it may be better to change that area.)
Recommended Posts