Introducing a dark Jupyter Notebook with pyenv and Vim keybindings on Ubuntu on WSL 2

Introduction

I introduced a dark Jupyter Notebook with pyenv and Vim key bindings on Ubuntu on WSL2, so I will summarize the procedure as a memorandum.

Installation environment

--Windows 10 version 20H2 (OS build 19042.508)

penv installation

Update the package list, update the package.

sudo apt update
sudo apt upgrade

After executing the above, log in to WSL again, install the following package, and log in again.

sudo apt install -y build-essential
sudo apt install -y libffi-dev
sudo apt install -y libssl-dev
sudo apt install -y zlib1g-dev
sudo apt install -y liblzma-dev
sudo apt install -y libbz2-dev libreadline-dev libsqlite3-dev 

Install pyenv and add environment variables to bashrc.

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

As an operation check, try installing the latest python3 series stable version.

#Check the installable version.
pyenv install --list
#python installation (3 in this procedure.8.5)
pyenv install 3.8.5
#Switch to the above version
pyenv global 3.8.5
#Version confirmation
python --version

pip installation

Install pip before Jupyter Notebook.

sudo apt install python3-pip
#Version confirmation
pip --version

Jupyter Notebook installation

Install Jupyter Notebook.

sudo -H apt install jupyter-notebook

Confirm startup.

jupyter notebook

Check the access of the following URL with a browser.

http://localhost:8888/

Set a login password.

jupyter notebook --generate-config
jupyter notebook password

Vim key binding settings

Install the Jupyter Notebook extension management package Nbextensions.

pip install jupyter_contrib_nbextensions

Install javascript and css of Nbextensions.

jupyter contrib nbextension install --user

Create a directory for extension deployment and make it the current directory.

mkdir -p $(jupyter --data-dir)/nbextensions
cd $(jupyter --data-dir)/nbextensions

Git clone the vim binding package.

git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding
jupyter nbextension enable vim_binding/vim_binding

Start Jupyter Notebook and use it if the following is displayed.

--The Nbextension tab is displayed. --Vim binding is displayed in the Nbextension list.

Jupyter Notebook Dark Mode Settings

Install the package jupyter themes for changing colors and fonts while Jupyter Notebook is stopped.

pip install jupyterthemes

Set it to look dark.

jt -t chesterish -T -f roboto -fs 9 -tf merriserif -tfs 11 -nf ptsans -nfs 11 -dfs 8 -ofs 8

When setting the key binding to Vim, set the display of insert mode and command mode to be dark.

cat <<EOL >> ~/.jupyter/custom/custom.css
.edit_mode .cell.selected .CodeMirror-focused.cm-fat-cursor {
        background-color: #000000 !important;
}
.edit_mode .cell.selected .CodeMirror-focused:not(.cm-fat-cursor) {
        background-color: #000000 !important;
}
div.CodeMirror-dialog.CodeMirror-dialog-bottom {
        background: #000000 !important;
}
EOL

References

I have summarized it as my own memorandum by referring to the following Qiita article. Thank you very much.

-When you apply Vim's power to Jupyter Notebook, both light and darkness look the strongest -Use vim on jupyter -Build Jupyter Notebook on WSL -Talk about installing pyenv on ubuntu 20.04

Recommended Posts

Introducing a dark Jupyter Notebook with pyenv and Vim keybindings on Ubuntu on WSL 2
Use cljstyle with Spacemacs on Ubuntu on WSL2
Build a DHCP and NAT router on Ubuntu 16.04
Create jupyter notebook with Docker and run ruby
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
What to do when booting Ubuntu on WSL2 and getting "Process terminated with code 1"
Install rbenv with apt on ubuntu and put ruby
Talk about introducing Ubuntu 20.04 on Windows 10 and text editor
ubuntu on wsl part 10
Set up Django on Ubuntu 16.04 with PostgreSQL and Gunicorn on ECS