Getting onto Jupyter Labs and Voila

Hey pa,
We talked on the phone briefly about voila; the new ‘pdf’, I called it. It’s an interactive web application, where you can ‘submit’ your work, publishable on a server. The front end and the back end are separated and the front end is an interactive page, where someone can explore your data or whatever else python program you have on there. It’s the R-Shiny app on python (if you’ve heard of that). I’d like to get you on that platform, to show you how eaaasssy it really is to start publishing stuff, once you’re learning python.

1. First let’s get started with conda. This is a very powerful package, but all we care about right now is the package manager.
https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html.

execute the following commands:

cd ~/wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; bash Miniconda3-latest-Linux-x86_64.sh

view the EULA and type yes.initialize conda by typing yes.close your terminal and open it again.you should see a new command prompt that says (base) before the username@machine
Note about CONDA: You’ve just opened the largest part of the terminal universe that I and other data scientists use. anything that’s available on these pages is now available on your terminal: https://anaconda.org/conda-forge/repohttps://anaconda.org/bioconda/repo.


(skip this step if you want to). Let’s make a new conda environment, just so that you can throw it away, if you want to give up on this project. Eventually, when you like Jupyter, you can install it on base (recommended). Perhaps the most useful feature of conda is that it’s a virtual environment manager, learn more about how to separate your projects/libraries in a way that you can experiment and throw away conda environments here(Bookmark this page)

conda create --name myenv

replace <myenv> with any name of your choice, for now, let’s call it jupyter and then let’s enter that environment

conda create --name jupyter
conda activate jupyter

the (base) should change to (jupyter) at this point. Anything you install from conda here will not exist in (base) and vice versa

conda deactivate

to go back to your home/base environment.


3. In your favorite conda environment, let’s install jupyter lab (this is basically the next version of Jupyter notebook)

conda install -c conda-forge jupyterlab

type when asked to confirm installation path.

4. Installing VoilĂ 
To install voila, go to your favorite conda environment and type the following.

conda install -c conda-forge voila

5. Downloading an example of Voila.There are many examples of Voila you can find here. Let’s go to the github page of the covid-plots project. And save the file “covid_it_fr_lag.ipynb” (or right click here and click `save link as`). Download the project.

Note on .ipynb format: This is the format for your jupyter notebooks. All projects you make on jupyter will be saved as .ipynb (read as: Interactive python notebook).

6.  Running Jupyter Lab and Viewing the source code in JupyterLab.

Open a terminal and type the following on your local machine to dedicate a terminal to the back end of Jupyter Lab (please don’t close this terminal, until the end of the session), it will also open a browser tab on your favorite browser.

jupyter lab

or…Type the following on a remote machine to for the same effect, this time you’ll get a link to click on.

jupyter lab --no-browser --ip=<enter your remote ip-address here>

like so.

jupyter lab --no-browser --ip=192.168.1.143

On the left panel, navigate your file system and find the covid_it_fr_lag.ipynb. click on it to open the Jupyter version of it. You can view the code here, in fact, this is the back end to a file that opens with also with a only the front end, display as well.

7. Installing final dependencies are crucial to see the script work, one could install these using conda. Open a terminal and enter these commands, so that python packages for your example code may be quickly installed.

conda install -c anaconda pandas -y ;\ 
conda install -c plotly plotly -y ;\
conda install -c conda-forge ipywidgets -y

8. Running Voila. open a terminal and type the following.

voila <path to downloaded file>

like so

voila ~/Downloads/covid_it_fr_lag.ipynb

and there we have it.. the new page with your data, to explore will open up, just as JupyterLab did, just this time around, you don’t see the code, you see only the front end of what the code plots.

—–
I hope you can appreciate how simple data science is becoming. However.. there is no shortcut to actually learning python. That’s the hard part. But I hope this tutorial inspires you to keep learning python, the world’s most popular programming language. 

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.