Book Image

Julia 1.0 Programming Cookbook

By : Bogumił Kamiński, Przemysław Szufel
Book Image

Julia 1.0 Programming Cookbook

By: Bogumił Kamiński, Przemysław Szufel

Overview of this book

Julia, with its dynamic nature and high-performance, provides comparatively minimal time for the development of computational models with easy-to-maintain computational code. This book will be your solution-based guide as it will take you through different programming aspects with Julia. Starting with the new features of Julia 1.0, each recipe addresses a specific problem, providing a solution and explaining how it works. You will work with the powerful Julia tools and data structures along with the most popular Julia packages. You will learn to create vectors, handle variables, and work with functions. You will be introduced to various recipes for numerical computing, distributed computing, and achieving high performance. You will see how to optimize data science programs with parallel computing and memory allocation. We will look into more advanced concepts such as metaprogramming and functional programming. Finally, you will learn how to tackle issues while working with databases and data processing, and will learn about on data science problems, data modeling, data analysis, data manipulation, parallel processing, and cloud computing with Julia. By the end of the book, you will have acquired the skills to work more effectively with your data
Table of Contents (18 chapters)
Title Page
Copyright and Credits
About Packt

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 theIJuliapackage. Press]in the Julia REPL to go to the Julia package manager and execute theadd IJuliacommand:

(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 thatyou 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:
  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"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( It is worth checking, as some details of the process described earlier may change.