Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Julia v0.5 on Ubuntu 16.04 while v0.6 is installed

I use v0.6, but certain packages do not function with v0.6 (such as Interact.jl). How can I install v0.5? I am running Ubuntu 16.04.

like image 630
Alejandro Braun Avatar asked Dec 06 '22 15:12

Alejandro Braun


1 Answers

First we have to download the latest Julia version from https://julialang.org/downloads/

I used the “Generic Linux Binaries for x86” version. The choice between x86 and ARM depends on the processor of your machine. Also choose between 32 bit and 64 bit versions based on the operating system and processor you have on your machine.

After download, you will get a compressed tar.gz archive having name similar to “julia-0.6.2-linux-x86_64.tar.gz”. As the “julia-0.6.2-linux-x86_64.tar.gz” name suggests that I downloaded the Julia version 0.6.2 which is latest at the time of writing this.

The names may differ. Adapt the names accordingly.

Remember these are binaries, these don't need to be installed as they can be directly used from the directory they are extracted.

I am assuming that the downloaded file is in your ~/Downloads directory of Ubuntu.

Open the terminal and navigate to the directory where the downloaded tar.gz file is stored, in present case the Downloads directory.

The terminal when just opened will show:

x@xpc:~$

where x should be replaced by your username and xpc should be replaced by your computer name.

Navigate to the Downloads directory using cd Downloads and then press Enter to get following terminal:

x@xpc:~/Downloads $

Extract the tar.gz file using the command

tar -zxvf julia-0.6.2-linux-x86_64.tar.gz

Now a directory with extracted contents will be generated in the same parent directory as of the compressed archive with a name similar to julia-xxxxxxxxxx where xxxxxxxxxx may be a combination of alphabets and numerals.

This is the final directory you need to run the latest Julia version, no installation is needed.

To run Julia, you can directly run using the julia file in location julia-xxxxxxxxxx/bin/julia as discussed below.

Navigate to the bin directory in the extracted directory using

cd /Downloads/julia-xxxxxxxxxx/bin

The terminal will now be like:

x@xpc:~/Downloads/julia-xxxxxxxxxx/bin $

Now run the command ./julia to run julia on the terminal as shown below.

The terminal will now change to julia as presented below. I know the representation is little different here as this is all I can manage to copy from the terminal to present it to you.

julia> But the problem is that I have to navigate to the directory every time to run Julia.

Many people have discussed on the internet about defining the path and alias through very complex procedures and as I am not a hardcore computer geek, it was really difficult for me to understand.

I came to know about making a soft link.

So I decided to make a soft link to the Julia to run it directly from anywhere with a short command without navigating to the directory containing it.

I always try to do things neatly, so I decided to keep the extracted directory named julia-xxxxxxxxxx in the /opt directory of my system as most of my important programs reside in that.

You need root permissions to copy a file into the /opt directory, so I used the command sudo su and then provided password to get the super user privileges:

x@xpc:~$ sudo su
[sudo] password for x:
root@xpc:/home/x#

Now navigate to the directory presently containing the extracted directory:

root@xpc:/home/x# cd /Downloads/
root@xpc:/home/x/Downloads#

Copy the directory using:

root@xpc:/home/x/Downloads# cp -r julia-xxxxxxxxxx /opt

After the directory is copied to the destination, now we will make the soft link in a directory which is in the system path so that the soft-link can be called from any location to run Julia.

To find out the directories in the system PATH use echo $PATH, you will get a list of paths of directories separated by colon(:) such as /usr/local/bin. You can use any of them. I used /usr/local/bin for the soft link.

Navigate to the chosen folder.

root@xpc:/home/x# cd /usr/local/bin

The terminal will become

root@xpc:/home/x/usr/local/bin#

Create the soft link using

root@xpc:/home/x/usr/local/bin# sudo ln -s /opt/julia-xxxxxxxxxx/bin/julia julia

Now return to the normal user terminal using the keyboard combination Ctrl+D at the empty terminal root@xpc:/home/x/usr/local/bin#.

The terminal prompt will become:

x@xpc:~$

Type the newly made soft link i.e. julia in the terminal as shown below

x@xpc:~$ julia
This is where the magic happens and you get this:

julia>

The instructions can be used for any version of Julia in Ubuntu.

Source

like image 175
Shiv Sharma Avatar answered Dec 08 '22 06:12

Shiv Sharma