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 Julia Command-Line
To start, open Julia’s command-line, also known as the REPL (read-eval-print-loop):
You would then see the following screen:
Step 2: Install the Package
Type the following command, and then press ENTER:
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:
Then, launch Jupyter Notebook by clicking on the Launch button within the Jupyter box:
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
Step 3: Install the Package
To install the DataFrames package, for example, type the following in Jupyter Notebook:
using Pkg Pkg.add("DataFrames")
Then click on Run:
The DataFrames package would now get installed: