{"id":186,"date":"2020-04-08T06:14:37","date_gmt":"2020-04-08T00:44:37","guid":{"rendered":"http:\/\/amit.fenn.net\/?p=186"},"modified":"2020-04-08T06:18:36","modified_gmt":"2020-04-08T00:48:36","slug":"getting-onto-jupyter-labs-and-voila","status":"publish","type":"post","link":"https:\/\/amit.fenn.net\/getting-onto-jupyter-labs-and-voila\/","title":{"rendered":"Getting onto Jupyter Labs and Voila"},"content":{"rendered":"\n

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.<\/p>\n\n\n\n

1. <\/strong>First let’s get started with conda<\/strong>. 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<\/a>.<\/p>\n\n\n\n

execute the following commands:
<\/p>\n\n\n\n

cd ~\/wget https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh<\/a>; bash Miniconda3-latest-Linux-x86_64.sh<\/pre>\n\n\n\n

view the EULA and type yes<\/strong>.initialize conda by typing yes<\/strong>.close your terminal and open it again.you should see a new command prompt that says (base) before the username@machine
Note about CONDA: <\/strong>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\/repo<\/a>, https:\/\/anaconda.org\/bioconda\/repo<\/a>.<\/p>\n\n\n\n


2 <\/strong>(skip this step if you want to).<\/strong> 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<\/a>(Bookmark this page)<\/strong>. 
<\/p>\n\n\n\n

conda create --name myenv<\/pre>\n\n\n\n

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

conda create --name jupyter<\/pre>\n\n\n\n
conda activate jupyter<\/pre>\n\n\n\n

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

conda deactivate<\/pre>\n\n\n\n

to go back to your home\/base environment.<\/p>\n\n\n\n


3. <\/strong>In your favorite<\/em> conda environment, let’s install 
jupyter lab<\/a> (this is basically the next version of Jupyter<\/a> notebook)
<\/p>\n\n\n\n

conda install -c conda-forge jupyterlab
<\/pre>\n\n\n\n

type y <\/strong>when asked to confirm installation path.
<\/p>\n\n\n\n

4.<\/strong> Installing Voil\u00e0
To install voila, go to your favorite conda environment and type the following.<\/p>\n\n\n\n

conda install -c conda-forge voila
<\/pre>\n\n\n\n

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

Note on .ipynb format<\/strong>: This is the format for your jupyter notebooks. All projects you make on jupyter will be saved as .ipynb (read as: Interactive python notebook).<\/p>\n\n\n\n

6.<\/strong>  Running Jupyter Lab and Viewing the source code in JupyterLab. <\/p>\n\n\n\n

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.
<\/p>\n\n\n\n

jupyter lab<\/pre>\n\n\n\n

or…Type the following on a remote machine to for the same effect, this time you’ll get a link to click on.<\/p>\n\n\n\n

<\/p>\n\n\n\n

jupyter lab --no-browser --ip=<enter your remote ip-address here><\/pre>\n\n\n\n

like so.<\/p>\n\n\n\n

jupyter lab --no-browser --ip=192.168.1.143
<\/pre>\n\n\n\n

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.<\/p>\n\n\n\n

7.<\/strong> 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.<\/p>\n\n\n\n

conda install -c anaconda pandas -y ;\\ \nconda install -c plotly plotly -y ;\\\nconda install -c conda-forge ipywidgets -y\n<\/pre>\n\n\n\n

8. <\/strong>Running Voila. open a terminal and type the following.<\/p>\n\n\n\n

voila <path to downloaded file>
<\/p>\n\n\n\n

like so<\/p>\n\n\n\n

voila ~\/Downloads\/covid_it_fr_lag.ipynb
<\/pre>\n\n\n\n

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.
<\/p>\n\n\n\n

—–
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. 
<\/p>\n","protected":false},"excerpt":{"rendered":"

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…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[39,9],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/posts\/186"}],"collection":[{"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":7,"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":196,"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/posts\/186\/revisions\/196"}],"wp:attachment":[{"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amit.fenn.net\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}