Packages

Author

Marie-Hélène Burle

Standard library

Julia comes with a collection of packages. In Linux, they are in /usr/share/julia/stdlib/vx.x.

Here is the list:

Base64
CRC32c
Dates
DelimitedFiles
Distributed
FileWatching
Future
InteractiveUtils
Libdl
LibGit2
LinearAlgebra
Logging
Markdown
Mmap
Pkg
Printf
Profile
Random
REPL
Serialization
SHA
SharedArrays
Sockets
SparseArrays
Statistics
SuiteSparse
Test
Unicode
UUIDs

Installing additional packages

You can install additional packages.
These go to your personal library in ~/.julia (this is also where your REPL history is saved).

All registered packages are on GitHub and can easily be searched here.
The GitHub star system allows you to easily judge the popularity of a package and to see whether it is under current development.

In addition to these, there are unregistered packages and you can build your own.

Your turn:

Try to find a list of popular plotting packages.

You can manage your personal library easily in package mode with the commands:

(env) pkg> add <package>   # install <package>
(env) pkg> rm <package>    # uninstall <package>
(env) pkg> up <package>    # upgrade <package>
(env) pkg> st              # st or status: list installed packages
(env) pkg> up              # up or upgrade: upgrade all packages

Replace <package> by the name of the package (e.g. Plots ).

You can install, uninstall, or update several packages at once by listing them with a space:

(env) pkg> add <package1> <package2> <package3>

An alternative to this convenience mode is to load the package manager (package Pkg, part of stdlib) and use it as you would any other package:

using Pkg

Pkg.add("<package>")        # install <package>
Pkg.rm("<package>")         # uninstall <package>
Pkg.status("<package>")     # status of <package>
Pkg.update("<package>")     # update <package>
Pkg.update()                # status of all installed packages
Pkg.status()                # update all packages

The short forms up and st do not work in this context.

To install, uninstall, or update several packages at once in this context, you need to create an array:

Pkg.add(["<package1>", "<package2>", "<package3>"])

Your turn:

Check your list of packages; install the packages Plots, GR, Distributions, StatsPlots, and UnicodePlot; then check that list again.

Your turn:

Now go explore your ~/.julia. If you don’t find it, make sure that your file explorer allows you to see hidden files.

Loading packages

Whether a package from the standard library or one you installed, before you can use a package you need to load it. This has to be done at each new Julia session so the code to load packages should be part of your scripts.

This is done with the using command (e.g. using Plots).