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 in Jupyter Notebook

Jupyter Notebook is a de facto standard for exploratory data science analysis. In this recipe, we show how to configure Jupyter with Julia.

Getting ready

Before installing Jupyter Notebook, perform the following steps:

  1. Prepare a Linux machine with Julia installed (you can follow the instructions in the Installing Julia from binaries recipe).

  2. Open a Julia console.

  3. Install the IJulia package. Press ] in the Julia REPL to go to the Julia package manager and execute the add IJulia command:

(v1.0) pkg> add 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...

Once IJulia is installed, there are two options for running Jupyter Notebook:

  • Running Jupyter Notebook from within the Julia console

  • Running Jupyter Notebook from bash

Running Jupyter Notebook from within the Julia environment

Simply start the Julia console and run the following commands:

julia> using IJulia

julia> notebook()

A web browser window will open with Jupyter, where you can start to work with Julia. In order to stop the Jupyter Notebook server, go back to the console and press Ctrl + C.

Running Jupyter Notebook outside of the Julia environment

In order to run Jupyter Notebook outside of Julia, firstly make sure that you have installed IJulia (see the Getting ready section). Once IJulia is installed, perform the following steps:

  1. Execute the shell command (this assumes that you used the default setting for the Julia packages folder; in particular the hsaaN part of the path below might be different; in such case please look-up the correct path in the ~/.julia/packages/Conda/ folder):
$ ~/.julia/packages/Conda/hsaaN/deps/usr/bin/jupyter notebook

Please note that the preceding command in Windows will look different:

C:\> %userprofile%\.julia\packages\Conda\hsaaN\deps\usr\Scripts\jupyter-notebook
  1. Look for console output similar to what is shown here:
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.

How it works...

Jupyter Notebook runs a local web server on port 8888. Once it is started, you can simply connect to it via a web browser. It is also possible to run such environments on a different machine than that used to access the notebook—please check the Jupyter in the cloud recipe for more details.

There's more...

Please note that for some packages, Julia installation might have conflicts with Windows security settings and thus prevent installation. In particular, IE Enhanced Security Configuration should be turned off (the default setting on Windows Server environments is on). In order to turn it off, open Server Manager and click Local Server, which is located on the left. In the right column, you will see the option IE Enhanced Security Configuration. Click on it to turn it off.

Another possible problem can be with the installation of IJulia, since it sometimes conflicts with an existing Python installation due to IJulia attempting to fetch and install a minimal Python environment itself. In such cases, if you get an error, run the following:

ENV["JUPYTER"] = "[path to your jupyter program]"
using Pkg

Pkg.build("IJulia")

You will have to manually find the [path to your jupyter program]. For example, on my Windows system with Anaconda installed, the path will be "C:\\Program Files\\Anaconda\\Scripts\\jupyter-notebook.exe". Note that we need to use two backslashes of the Julia string to represent a single backslash in a path. If you have provided a proper path, the build should finish successfully.

See also

The most recent documentation can be found on IJulia's website (https://github.com/JuliaLang/IJulia.jl). It is worth checking, as some details of the process described earlier may change.

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