Installing and working with IJulia
IJulia (https://github.com/JuliaLang/IJulia.jl) is a combination of the IPython web frontend interactive environment (http://ipython.org/) with a Julia-language backend. It allows you to work with IPython's powerful graphical notebook (which combines code, formatted text, math, and multimedia in a single document) with qtconsole
and regular REPL. Detailed instructions for installation are found at the GitHub page for IJulia (https://github.com/JuliaLang/IJulia.jl) and in the Julia at MIT notes (https://github.com/stevengj/julia-mit/blob/master/README.md). Here is a summary of the steps:
- Install Version 1.0 or later of IPython via
easy_install
orpip
(on OS X and Windows, this is included in the Anaconda Python installation). On Linux, useapt-get install ipython
. (For more information, refer to the IPython home page). - Install
PyQt4
orPySide
forqtconsole
. - Install the IJulia package from the REPL with
Pkg.add("IJulia")
. - Install the PyPlot package with
Pkg.add("PyPlot")
.
You can work with IJulia in either of two ways:
- Start an IPython notebook in your web browser by typing the following command in a console:
ipython notebook --profile julia
- Start
qtconsole
with:ipython qtconsole --profile Julia
Verify that you have started IJulia. You must see IJ and the Julia logo in the upper-left corner of the browser window. Julia code is entered in the input cells (input can be multiline) and then executed with Shift + Enter. Here is a small example:
In the first input cell, the value of b
is calculated from a
:
a = 5 b = 2a^2 + 30a + 9
In the second input cell, we use PyPlot
(this requires the installation of matplotlib
; for example, on Linux, this is done by sudo apt-get install python-matplotlib
).
The linspace(0, 5)
command defines an array of 100 equally spaced values between 0
and 5
, y
is defined as a function of x
and is then shown graphically with the plot as follows:
using PyPlot x = linspace(0, 5) y = cos(2x + 5) plot(x, y, linewidth=2.0, linestyle="--") title("a nice cosinus") xlabel("x axis") ylabel("y axis")
Save a notebook in file format (with the extension .ipynb
) by downloading it from the menu. If working in an IPython notebook is new for you, you can take a look at the demo at http://ipython.org/notebook.html to get started. After installing a new Julia version, always run Pkg.build("IJulia")
in the REPL in order to rebuild the IJulia package with this new version.