If the previous section convinced you to use Julia for your next project, or at least made you curious to learn more, then it's time to set up your Julia development environment.
Julia has superb cross-platform support, running on all major operating systems. The install process is straightforward—the language can be set up on your local machine, in a virtual machine (VM), in a Docker container, or on a server somewhere in the cloud.
Let's start by looking at local installation options for the big three operating systems (Windows, Linux, and macOS). Feel free to skip directly to the right one for you.
Windows has come a long way as a development platform and there are a few good alternatives for getting Julia up and running.
The simplest option is to download the Windows installer corresponding to your platform (32 or 64-bit), from https://julialang.org/downloads/. Get the .exe
and run it. Follow the standard installation procedure and in the end, you will have Julia installed as a program. Double-clicking julia.exe
opens a command prompt with the Julia REPL, just like the one illustrated here:
Chocolatey is a package manager for Windows, similar to apt
or yum
on Linux, or brew
on Mac. If you don't have it, get it by following the instructions at https://chocolatey.org.
Chocolatey has the latest version of Julia, as can be confirmed with a search, as follows:
$ choco search julia
Chocolatey v0.10.11
Julia 1.0.0 [Approved]
1 packages found.
Installing is as simple as this:
$ choco install julia Chocolatey v0.10.11 Installing the following packages: julia By installing you accept licenses for the packages. Progress: Downloading Julia 1.0.0... 100% Julia v1.0.0 [Approved] Chocolatey installed 1/1 packages.
One of the recent additions to Windows 10 is the Subsystem for Linux. This allows setting up a Linux development environment, including most command-line tools, utilities, and applications—directly on Windows, unmodified, and without the overhead of running a VM.
In order to be able to use the Linux Subsystem your PC must be running the 64-bit version of Windows 10 Anniversary Update or later (build 1607+). It also needs to be enabled first—so open a PowerShell as an administrator and run the following:
$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Once the subsystem is enabled (computer restart might be required) you can choose one of the Linux versions available, directly from the Windows Store. At the time of writing, five versions were available—Ubuntu, openSUSE , SLES, Debian, and Kali.
Ubuntu is the default option for Windows 10 and has the best user ratings in the Windows Store, so let's go with that. It can be installed from https://www.microsoft.com/en-us/store/p/ubuntu/9nblggh4msv6. Alternatively, you can just open a command prompt and type $ bash
. This will trigger the installation of the Ubuntu Linux Subsystem.
Once you find yourself at the shell prompt of your Linux subsystem, you can proceed and issue the commands for installing Julia. For Ubuntu you need to run the following:
$ sudo apt-get install julia
Make sure to confirm the required selections—then after a couple of minutes you should have Julia up and running.
Installing Julia on macOS is straightforward. There are two main options, depending on whether you prefer a visual installer or are more at home in front of the Terminal prompt.
Visit https://julialang.org/downloads/ and look for the macOS package (.dmg
). Once it's downloaded, double-click the .dmg
file and drag and drop the Julia app into the /Applications
folder. Now you can simply open the Julia app—which in turn will launch a new Terminal session, loading the Julia environment, as follows:
Homebrew
is a well-known package manager for macOS in the line of apt
and yum
on Linux. It's not really necessary for installing Julia, but it's worth setting it up as it can be very useful during development since it can seamlessly install database servers, libraries, and other components for your projects.
As per the instructions at https://brew.sh, it can be installed by running the following command in a Terminal window:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It might take a while but once Homebrew
is installed, a new command-line utility, brew
, will become available.
Finally, $ brew cask install julia
will download and install the latest version of Julia. In the process, it will also link the julia
binary to /usr/local/bin/julia
so you can interact with the language from the command line by simply typing $ julia
.
As soon as you get the confirmation that the installation was successful you can run $ julia
to start a new REPL session:
Julia is already available in the software repositories of the major Linux distributions, but unfortunately, these are not up to date. For example, at the time of writing, Ubuntu was providing v0.4.5 and Debian v0.4.7. The best approach is to use the generic Linux binaries provided on Julia's download page, at https://julialang.org/downloads/.
Please follow the instructions corresponding to your Linux distribution, as indicated at https://julialang.org/downloads/platform.html#generic-binaries.
Docker is a software technology that provides an additional layer of abstraction of operating-system-level virtualization. In plain English, Docker sets up containers that behave like VMs, but without the added overhead of starting and maintaining VMs. You can run Docker on all the major operating systems.
Docker is widely used as a development and deployment strategy, so many technologies are readily available in the form of Docker images, and Julia is no exception.
Start by installing Docker for your platform. The official Julia container can be found in the Docker store at https://store.docker.com/images/julia. Go get it.
Note
If you need help setting up Docker or installing containers, follow the instructions at https://www.docker.com.
At the command prompt, type $ docker pull julia
. Once the Julia image is configured by Docker, run it with $ docker exec -it --rm julia
. This will start the container and load a new Julia REPL:
Julia Computing, the company behind the Julia programming language, offers a batteries included distribution. It's called JuliaPro and it's arguably the easiest way to get started with Julia straight away. It includes the compiler, a profiler, the Juno IDE, and over 160 top quality curated packages for plotting, data visualization, machine learning, databases, and more.
JuliaPro can be downloaded for free at https://shop.juliacomputing.com/Products/ (registration required). Once you get it, follow the install process specific to your platform. When done you'll have everything needed to begin using Julia productively.
Finally, there's also JuliaBox (https://www.juliabox.com), another free offering from Julia Computing. JuliaBox allows running a Julia Docker container on the fly, in their cloud. It provides access to IJulia Jupyter notebooks (https://github.com/JuliaLang/IJulia.jl), file sync with Google Drive, importing GitHub repositories, and many other features.
Note
If you are not familiar with Jupyter notebooks, you can learn more about them by visiting http://jupyter.org.