How to Install a Package in Julia (Example Included)

In this short post, I’ll show you how to install a package in Julia.

The general code to install a package in Juila is:

using Pkg
Pkg.add("Package Name")

For demonstration purposes, I’ll show you the steps to install the DataFrames package.

Steps to Install a Package in Julia

Step 1: Open the Julia Command-Line

To start, open the Julia command-line, also known as the REPL (read-eval-print-loop):

Open Julia

You would then see the following screen:


Step 2: Install the Package

Type the following command, and then press ENTER:

using Pkg
using Pkg Julia

To install the DataFrames package, type the command below, and then press ENTER:


You’ll need to wait about a minute for the installation to complete…


Mission accomplished. You can now enjoy the DataFrames package.

Note that the same principles you just reviewed can also be used to install other packages in Julia.

But what if you’d like to install a package in Julia using Jupyter Notebook?

You can certainly do that using the steps described below. But before you execute these steps, make sure to add Julia to Jupyter Notebook.

Steps to Install a Package in Julia using Jupyter Notebook

Step 1: Launch Jupyter Notebook

If you are using the Anaconda Distribution, you can launch Jupyter Notebook by opening the Anaconda Navigator:

Anaconda Navigator

Then, launch Jupyter Notebook by clicking on the Launch button within the Jupyter box:

Launch Jupyter for Julia

Step 2: Create a New Julia Notebook

To create a new Julia Notebook:

  • First, click on New
  • Then, select Julia from the drop-down list
Julia Jupyter

Step 3: Install the Package

To install the DataFrames package, for example, type the following in Jupyter Notebook:

using Pkg
Install a Package in Julia

Then click on Run:

Add DataFrames

The DataFrames package would now get installed:

Install package in Julia