logo

Installing and Using Packages in Julia 📂Julia

Installing and Using Packages in Julia

Method 1

using LinearAlgebra
using Pkg

Pkg.add("Plots")
Pkg.add("Distributions")

using Plots

The above code demonstrates importing the LinearAlgebra and Pkg packages and installing the Plots, Distribution packages using the .add() function. The keyword using to import packages is somewhat reminiscent of the language used in mathematics when applying a theorem or argument. Installing packages is more akin to R than Python, and its usage closely resembles that of Python. Similar to R, package names must be enclosed in double quotes, and it’s common to write package names in Pascal Case1 and frequently append an -s to make them plural2, which can be confusing.

Method 2

5FED66B31.png

By typing ] in the REPL, you switch to the Package Manager environment as shown above. Pressing backspace will take you back to the REPL environment. Entering add package_name in the package manager environment will install the specified package.

(@v1.5) pkg> add Plots
  Resolving package versions...
Updating `C:\Users\rydbr\.julia\environments\v1.5\Project.toml`
  [91a5bcdd] + Plots v1.0.14
No Changes to `C:\Users\rydbr\.julia\environments\v1.5\Manifest.toml

  1. A notation method that capitalizes the first letter of each word. As seen in the example code, linear algebra is written as LinearAlgebra, with the first letter of each word capitalized and spaces omitted. ↩︎

  2. As seen in the example code, Plot and Distribution need to be referred to as Plots and Distributions, respectively. ↩︎