Installing and configuring Jupyter Lab on Windows

Jupyter lab is an interactive development environment and the way forward for people using Jupyter notebook. It has become one of the most preferred ways to code in data science field and academia. Notebook cell-based structure was very convenient for doing data exploration, model building etc. but it was lagging in creating and running scripts or code from text files(.py, .R etc). Jupyter lab has removed these shortcomings and has added new useful features such as running code blocks from text files, edit and view popular data files, rearrange cells by dragging them etc. In this post, I will discuss how to install and configure it on windows so that it is more convenient to use.

Installing Jupyter Lab

Installing jupyter lab is very easy and might depend on how you have installed python. If you are using anaconda then most probably jupyter lab is already there. If not you can install it using the command:-

conda install -c conda-forge jupyterlab

If you are not using anaconda and have installed python separately, you can install it using

Pip install jupyter
Pip install jupyterlab

It is important to have Jupyter notebook installed before installing Jupyter Lab. The first command installs Jupyter notebook in your system. You can skip it if it is already installed. Now, Let’s launch Jupyter lab by typing jupyter lab in command prompt.

installing & configuring jupyter lab
Jupyter lab

Changing default directory

By default, Jupyter lab set up c:/users/username as the default directory. As can be seen in the above picture, it will show all of the files in that folder which can make the whole setup very cluttered. We can change the default directory so that it is easier to manage projects. For changing it, we will need to first generate jupyter lab configuration file.

Jupyter notebook --generate-config

This will create a configuration file at  c:/users/username/.jupyter/

Now, we can edit default directory location in this configuration file by defining the value of #c.NotebookApp.notebook_dir = ”. You will need to uncomment this by removing # and store the path of default desired directory there. You should use double quotes if there is any space in the directory path.

After changing the directory, relaunch the jupyter lab again. You will notice that project view has fewer files and directory.

changing default directory in jupyter lab
After changing default directory in Jupyter Lab

Running it in chrome application mode

We can use application mode of chrome browser to convert Jupyter Lab in a standalone desktop app. It is useful as it will remove all the unnecessary toolbars and UI and gives a feeling of native application or IDE rather than a website running on your browser.

There are two ways to do this. Either you can launch in this mode manually every time or we can save configuration for this in jupyter lab configuration file and make it as our default launch.

Let’s first do it manually:-

$ jupyter lab --no-browser

It will launch Jupyter  Lab without any browser. You will need to copy the token from the command prompt.  After this start chrome in application mode and paste above token by typing below command in windows search bar

Chrome.exe --app=copied token

We can also put these options in the configuration file and make it default launch by adding following in the notebook config file

c.NotebookApp.browser = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe --app=%s"

It will launch Jupyter Lab like a standalone desktop app

Jupyter lab as a desktop application
Jupyter Lab as chrome application

Changing theme and making a shortcut for it

Jupyter lab has two inbuilt theme light and dark. Light theme is also the default one and you can switch to dark one by going to setting in Jupyter lab and clicking on Jupyeterlab Dark.

theme-Jupyter lab
Selecting theme in Jupyter Lab

Also, we can make a shortcut on our desktop to launch jupyter. Follow this path Right click on the desktop > New > Shortcut to create a shortcut link. It will open a window and will ask you to input location path. You will need to input jupyterlab.exe path here. It will be in your python installation folder > scripts folder.

Click on next and give any name you want to and finish. Now you can see this shortcut on your desktop and click on it will launch jupyter lab. If you have any icon file then you can also use that to set an icon for this application by giving the path of the icon file in properties options.

Jupyter Lab is becoming one of the most convenient tools for the data scientist. By converting and configuring it, it becomes more convenient and easier to work with. Considering that you will be spending most of your time on this tool, it is important to use the most useful and comfortable tool. You can also look into installing few useful extensions on it so to expand its utility.

Leave a Comment

Your email address will not be published. Required fields are marked *