How To Setup Julia For Data Science | by Emmett Boudreau | Towards Data Science

The Julia programming language is a relatively young language that has taken the world of Data Science by storm in recent years. This is because the Julia language’s features facilitate scientific computing and machine-learning very well. This is because of a rigid combination of numerical accuracy, calculation speed, and scientific syntax. Considering all of these attributes of the language, it is easy to see why any Data Scientist might be considering picking up the programming language. However, when picking up the language it is likely that you will encounter the largest problem with the Julia programming language, its popularity.
Compared to most other programming languages, Julia has a very low adoption rate and a lot smaller user-base and package ecosystem than most of the other statistical languages that it is competing with. This can make the language a lot more difficult to learn just because there are far fewer resources available. Furthermore, if it is too difficult for some users to even get the language operating properly on their machine, it is unlikely that these users are going to be getting very familiar with the language beyond what is on the website.
Of course, in this regard, the first step towards getting Julia set up is going to be actually installing the programming language. Of course, this process is going to be dramatically different depending on what operating system you might be running. On most unix-like operating systems like MacOS, Linux, and FreeBSD the package is going to be available in your package manager. However, I would like to point out that this is probably not the way that you should install the Julia language on these systems. This is because these package manager versions are often very outdated, and in some instances, you might end up with an ancient and essentially useless version of Julia. Even in scenarios where the version is above the 1.0 breaking release, you might find that there are many features that are left out and documentation that might not be accurate. Furthermore, compatibility is always a large concern when it comes to working with packages in the ecosystem.
On these Unix-like systems, I certainly recommend downloading the language directly from the Julia website. In this regard, the first step is going to likely be downloading the file and placing it in a desired directory. I typically do this with wget in bash, but there is essentially no difference at all between doing this in the web-browser or the terminal. After the package is downloaded and extracted, the next step is going to be to add the path to your system so that your system knows where your Julia installation is actually located. On Linux, we can do this by editing our ~/.bashrc or ~/.bash_profile file.
wget https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.0-linux-x86_64.tar.gztar zxvf julia-1.6.0-linux-x86_64.tar.gz
Now we will add this line into our ~/.bashrc
export PATH="$PATH:/julia/directory"
I typically place this along with my net-wide assembler in /opt, but you could essentially place it anywhere under your root file system.
As for installation on MacOS, the process starts with a Julia dmg file provided on the website. Optionally, you can add the call to PATH using ln:
ln -s /Applications/Julia-1.6.app/Contents/Resources/julia/bin/julia /usr/local/bin/juli
For Windows, we will of course run an executable .exe file as you might typically do with any application on this operating system. After that, you might want to add the PATH just as before. Of course, this is a little different with the MSDOS-based NT command terminal thing that you get on Windows. The process for adding this to PATH goes a little something like this in Windows:
Open Run (Windows Key + R), type in rundll32 sysdm.cpl,EditEnvironmentVariables and hit enter.Under either the “User Variables” or “System Variables” section, find the row with “Path”, and click edit.The “Edit environment variable” UI will appear. Here, click “New”, and paste in the directory noted from the installation stage. This should look something like C:\Users\JohnDoe\AppData\Local\Programs\Julia 1.6.0\bin.Click OK. You can now run Julia from the command line, by typing julia!
Open Run (Windows Key + R), type in rundll32 sysdm.cpl,EditEnvironmentVariables and hit enter.
Under either the “User Variables” or “System Variables” section, find the row with “Path”, and click edit.
The “Edit environment variable” UI will appear. Here, click “New”, and paste in the directory noted from the installation stage. This should look something like C:\Users\JohnDoe\AppData\Local\Programs\Julia 1.6.0\bin.
Click OK. You can now run Julia from the command line, by typing julia!
When it comes to development environments with Julia, there are a lot of different options that I personally think are all awesome.
Firstly, in the world of notebooks we have three options:
IJulia.jl
Pluto.jl
Neptune.jl
All of these are Julia packages that we will need to add, so in order to get a notebook server up we might want to first figure out which notebook server is going to be the most apt for our work. Personally, I prefer good-ole Jupyter to both Pluto and Neptune, which I believe can be a bit of a headache and have a decent way to go when it comes to actually being stable and working really well. I wrote an opinionated article on this exact topic that you could check out here in order to find out if Pluto.jl might be for you:
towardsdatascience.com
That being said, an advantage to using a solution like Pluto or Neptune is that both of these notebook servers are written in the Julia programming language. In other words, we can cut out the middle man with the IPython kernels and run the Julia directly through itself, which can certainly present some performance benefits. Furthermore, Pluto and Neptune files are stored in .jl Julia files, rather than IPython notebook files — which is pretty cool, because then you can write your code one time and have it work from both the REPL and the notebook.
To elaborate, Neptune.jl is a rather recently released modification of Pluto.jl. The Neptune.jl implementation actually gets rid of a lot of the problems I had with Pluto.jl. These examples include the interactivity, which can sometimes even be a little invasive and get in between you and writing the code. IJulia is just a Jupyter kernel for Julia, which for me has been the most effective solution for my personal preferences. That being said, there is no harm in trying this out.
With that in mind, all we really need to do in order to work with these packages is add them through Julia’s package manager, Pkg. This is of course with the exception of IJulia, which is going to require a Jupyter installation in order to properly work. In order to add these packages, we first need to get into the Julia REPL. You can do this universally on all the operating systems by typing “ julia” into your terminal or command window. Once you are in the Julia REPL, you can press ] to enter the Pkg REPL. Although Pkg itself is a package that you can always call from Julia, I certainly prefer to use this method. Now we can use the add command with a package as an argument in order to add our packages:
julia > ]pkg > add IJuliapkg > add Plutopkg > add Neptune
With IJulia, the Julia kernel should now appear in your kernel list in Jupyter, and that is really all there is to it. With Neptune and Pluto, you will need to import the package and use the run() function in order to start your server.
using Neptune; Neptune.run()using Pluto; Pluto.run()
In addition to having a notebook server, you might also want a development environment for regular text. For that, my favorite solution is Atom with Juno. However, there is also a VSCode development environment available that I have never used. Juno is actually technically deprecated — well, not deprecated, but the only updates it receives are security and bug fixes, no new features are planned to be added to the Juno package. As with most instances of Atom packages, you can install it by first going into your menu bar and selecting edit>preferences.
This will bring up a preference menu. Along the left side of this menu you should see a little plus sign that says “ install,” there you can install Juno. This will also install the Juno.jl package, and boom! You can now edit Julia text!
The last thing that one might want in order to work with the Julia language is the ability to work with virtual environments. In Julia, this process is incredibly easy and done completely through the Pkg package manager. We can call the activate command or method from Pkg in order to create a new virtual environment. This will create a folder with a Project.toml file inside of it. This project file will contain all of the dependencies for your project, and is shaped like a typical configuration file.
julia > ]pkg > activate env
The Julia language has certainly jumped in popularity over the past year or two. This is because of all the Data Science-centric features available in the language, as Data Science has become a rather popular topic in the world of computing as of lately. I think that with this new set of users, many are bound to be lost on the installation process alone. With that in mind, I hope this article was successful at solving that problem — and if that problem was never had, perhaps it might have sparked a little interest in the language! What is great about that is now you also know how to install it!