Member-only story
How to prettify your code in a Jupyter Notebook
Use the Code Prettify Jupyter Extension
Sometimes when writing code in a Jupyter notebook, you may be in a hurry and don’t want to spend time on arranging your code, using proper indentation, and stuff like that. So, wouldn’t be nice if there would be a tool to solve this issue? Well… there is. There is a Jupyter extension that does exactly that: Code Prettify Jupyter Extension.
Let’s see below how we can install and use it.
Installation
Firstly, we need to install the jupyter_contrib_nbextensions
python package. This package will then be used to install the extensions and to activate/deactivate a certain extension.
pip install jupyter_contrib_nbextensions
Then, we need to install the extensions themselves. And what this means is that we basically copy all the javascript and CSS files of all available extensions to the Jupyter data directory and then edit the relevant config files. In Windows, the folder in which these extensions are copied is %APPDATA%\jupyter
, in Linux is ~/.local/share/jupyter
, and in Mac is ~/Library/Jupyter
.
Below is the command that does these things:
jupyter contrib nbextension install --user