Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
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

Product type Book
Published in Nov 2018
Publisher Packt
ISBN-13 9781788998369
Pages 460 pages
Edition 1st Edition
Languages
Authors (2):
Bogumił Kamiński Bogumił Kamiński
Profile icon Bogumił Kamiński
Przemysław Szufel Przemysław Szufel
Profile icon Przemysław Szufel
View More author details
Toc

Table of Contents (18) Chapters close

Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
1. Installing and Setting Up Julia 2. Data Structures and Algorithms 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 1. Other Books You May Enjoy Index

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

Note

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:
    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.

You have been reading a chapter from
Julia 1.0 Programming Cookbook
Published in: Nov 2018 Publisher: Packt ISBN-13: 9781788998369
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 €14.99/month. Cancel anytime}