Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Julia 1.0 Programming Cookbook

You're reading from   Julia 1.0 Programming Cookbook Over 100 numerical and distributed computing recipes for your daily data science work?ow

Arrow left icon
Product type Paperback
Published in Nov 2018
Publisher Packt
ISBN-13 9781788998369
Length 460 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Przemysław Szufel Przemysław Szufel
Author Profile Icon Przemysław Szufel
Przemysław Szufel
Bogumił Kamiński Bogumił Kamiński
Author Profile Icon Bogumił Kamiński
Bogumił Kamiński
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Installing and Setting Up Julia 2. Data Structures and Algorithms FREE CHAPTER 3. Data Engineering in Julia 4. Numerical Computing with Julia 5. Variables, Types, and Functions 6. Metaprogramming and Advanced Typing 7. Handling Analytical Data 8. Julia Workflow 9. Data Science 10. Distributed Computing 11. Other Books You May Enjoy

Configuring Julia to work with JupyterLab

JupyterLab is a new, extended version of Jupyter Notebook. Before installing it, make sure that you have successfully completed the Configuring Julia in Jupyter Notebook tutorial. Running JupyterLab requires Python to be installed. We strongly recommend Python Anaconda as the standard execution environment.

Getting ready

The configuration of JupyterLab requires having IJulia configured on your system:

  1. Prepare a Linux or Windows machine with Julia installed.

  2. Follow the Configuring Julia in Jupyter Notebook tutorial and install IJulia.
In the GitHub repository for this recipe, you will find the commands.txt file that contains the presented sequence of shell and Julia commands.

How to do it...

By default, Julia does not include JupyterLab. However, it is possible to add JupyterLab by using the Conda.jl package. We will show, step-by-step, how to add JupyterLab to a Julia installation and run it from bash:

  1. Press the ] key to go to the Julia package manager and install the Conda.jl package:
(v1.0) pkg> add Conda
  1. Use Conda to add JupyterLab to Julia's installation:
julia> using Conda

julia> Conda.add("jupyterlab")
  1. Once JupyterLab is installed, exit Julia and run it from the command line:
$ ~/.julia/packages/Conda/hsaaN/deps/usr/bin/jupyter lab
  1. Please note that the preceding command in Windows will look different:
C:\>%userprofile%\.julia\packages\Conda\hsaaN\deps\usr
\Scripts\jupyter-lab
  1. If the preceding command did not automatically start the web browser, do it manually and look for console output similar to this:
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=b86b66b81a62d4be1ae34e7d6bd006a8ba5cb937e74b99cf
  1. Paste the link (in the preceding output marked with bold font) into your browser's address bar.

Once you have followed the preceding steps, you should see in the browser a screen similar to the one shown here (please note that since Python is installed with IJulia.jl, it is also available alongside Julia):

How it works...

JupyterLab is an extension of Jupyter Notebook and hence it works in a very similar fashion. JupyterLab runs a local web server on port 8888 (the same port that would have been used by Jupyter Notebook). Once it is started, you can simply connect to it via a web browser. It is also possible to run such environments on a separate machine. Please check the Configuring Julia with Jupyter Notebook headless cloud environments recipe for more details (that recipe is valid for both Jupyter Notebook and JupyterLab).

There's more...

Yet another option is to use JupyterLab from a completely external Anaconda installation. Since the installation process differs for Linux and Windows, we present both versions.

Running JupyterLab with Anaconda on Linux

In order to install JupyterLab on Linux, perform the following steps:

  1. Go to the Anaconda for Linux download website (https://www.anaconda.com/download/#linux) and find the current download link for the 64-bit Python 3 version (usually it can be done in a web browser by right-clicking the Download button and selecting Copy link location).
  2. Download Anaconda Python. Please note that depending on the time when you perform the installation, the exact link might look different—new Anaconda versions are being released frequently:
$ wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh
  1. Run the Anaconda installer:
$ sudo bash Anaconda3-5.3.0-Linux-x86_64.sh
  1. Now, you can launch JupyterLab (we assume that you have selected the standard install locations):
$ /home/ubuntu/anaconda3/bin/jupyter lab
  1. If the preceding command did not automatically start the web browser, do it manually and look for console output similar to this:

[I 11:07:55.625 LabApp] The Jupyter Notebook is running at:
[I 11:07:55.625 LabApp] http://localhost:8888/?token=c3756ac2013d780af16b0401d67ab017c5e4a17cc9bc7924
[I 11:07:55.625 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 11:07:55.625 LabApp] No web browser found: could not locate runnable browser.
  1. Paste the link (in the preceding log marked with bold font) your browser's address bar.

Please note that if you follow the preceding steps (including the installation of the IJulia.jl package), once you open the JupyterLab welcome screen, you should see Python 3 as well as Julia Notebook execution kernels.

Running JupyterLab with Anaconda on Windows

In the following steps, we describe to run JupyterLab with Anaconda on Windows:

  1. Go to the Anaconda for Windows download website (https://www.anaconda.com/download/#windows) and find the current download link for the 64-bit Python 3 version. Download the *.exe installation file to your computer.
  2. Run the installer. Here, we assume that you are installing it to the default folder, which on Windows is C:\ProgramData\Anaconda3\.
If you decide to install to a different location, make sure that the path contains no spaces.
  1. Once Anaconda 3 is installed, simply run jupyter-lab.exe:
C:\> C:\ProgramData\Anaconda3\Scripts\jupyter-lab.exe
  1. If the preceding command did not automatically start the web browser, do it manually and look for console output similar to this:
Copy/paste this URL into your browser when you connect for the first time,  to login with a token:
http://localhost:8888/?token=7f211507e188ecfc22e2858b195c8de915c7c221f012ee86
  1. Paste the link (in the preceding log marked with bold font) into your browser's address bar.

Please note that if you follow the preceding steps (including the installation of the IJulia.jl package), once you open the JupyterLab welcome screen, you should see Python 3 as well as Julia Notebook execution kernels.

See also

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime