Julia's package manager, Pkg, is used to find, add, and manage external libraries that extend Julia's capabilities for projects. These packages are collections of pre-written code that provide specialized functionalities, from data analysis tools to plotting libraries.
The Julia ecosystem is rich and growing. Finding the right package for your needs is an important first step. Here are common places to look:
When you find a package, pay attention to its documentation, number of stars/forks (on GitHub, as a rough gauge of popularity/maintenance), and recent activity to assess its suitability.
The most common way to manage packages is through Pkg's special mode within the Julia REPL. You can enter this mode by typing ] at the Julia prompt:
julia> ]
pkg>
Notice the prompt changes from julia> to pkg>. All commands you type in this mode are Pkg commands. To exit Pkg mode and return to the standard Julia REPL, simply press Backspace or Ctrl+C on an empty line.
Once you've identified a package you want to use, you can add it to your current project environment. The command for this is add. For example, to add the popular DataFrames package, you would type:
pkg> add DataFrames
When you issue this command, Pkg performs several actions:
DataFrames and its dependencies (other packages it needs to function).DataFrames and all its dependencies that are compatible with each other and with other packages already in your project.Project.toml and Manifest.toml files.
Project.toml lists the direct dependencies of your project (e.g., DataFrames).Manifest.toml records the exact versions of all packages (direct and indirect dependencies) that were resolved, ensuring reproducibility.You can also add multiple packages at once:
pkg> add DataFrames Plots StatsBase
If you need a specific version of a package, you can specify it using @:
pkg> add [email protected]
Or, to get the latest version within a specific major or minor version range:
pkg> add Example@1 # latest 1.x.y
pkg> add [email protected] # latest 1.2.x
Adding a package makes its code available to your Julia environment, but to use its functions and types in your script or REPL session, you need to load it. This is typically done with the using keyword:
julia> using DataFrames
julia> df = DataFrame(A = 1:3, B = ['x', 'y', 'z'])
3×2 DataFrame
Row │ A B
│ Int64 Char
─────┼─────────────
1 │ 1 x
2 │ 2 y
3 │ 3 z
After using DataFrames, all exported functions and types from DataFrames (like the DataFrame constructor itself) are available directly.
Alternatively, you can use import. The main difference is that import PackageName requires you to qualify all names with the package name (e.g., DataFrames.DataFrame). import PackageName: name1, name2 brings only specific names into scope. For most interactive use and general scripting, using is more common.
julia> import DataFrames
# You must qualify the name:
julia> df = DataFrames.DataFrame(ID = [1, 2], Value = [10.0, 20.5])
2×2 DataFrame
Row │ ID Value
│ Int64 Float64
─────┼────────────────
1 │ 1 10.0
2 │ 2 20.5
To see which packages are installed in your current environment and their versions, use the status command (or its abbreviation st) in Pkg mode:
pkg> status
or
pkg> st
This will output a list of packages in your Project.toml file along with their versions and potentially a short unique identifier (UUID).
pkg> st
Status `~/my_julia_project/Project.toml`
[336ed68f] CSV v0.10.11
[a93c6f00] DataFrames v1.6.1
[91a5bcdd] Plots v1.39.0
The output shows the packages directly added to this project environment, along with their installed versions.
Package developers regularly release new versions with bug fixes, performance improvements, and new features. To update all packages in your environment to their latest compatible versions, use the update command (or up):
pkg> update
This will check the registry for newer versions of all your dependencies, respecting compatibility constraints. If you want to update only a specific package, you can name it:
pkg> update DataFrames
It's generally a good practice to update your packages periodically.
If you no longer need a package in your project, you can remove it using the rm command:
pkg> rm DataFrames
This will remove DataFrames from your Project.toml and, if no other package needs them, will also remove its dependencies from Manifest.toml and your system (though often packages are just un-tracked, not immediately deleted from disk, to speed up future re-adds).
As you work with Pkg, you'll notice the mentions of Project.toml and Manifest.toml. These files are central to Julia's environment system. Each project can have its own independent set of package versions. This is incredibly useful for reproducibility and avoiding conflicts where one project needs an older version of a package and another project needs a newer one.
When you start Julia, it's typically in a default global environment. However, for serious work, you'll want to create project-specific environments. The Pkg.activate(".") command (run in the Julia REPL, not Pkg mode) tells Julia to use or create Project.toml and Manifest.toml files in the current directory. Any add, rm, or update commands will then apply to that project's environment. We will cover setting up projects in more detail in the next section.
Effectively finding, adding, and managing packages is a fundamental skill for any Julia programmer. It allows you to tap into the library of tools created by the community, significantly speeding up your development and expanding what you can achieve with Julia.
Was this section helpful?
using and import.© 2026 ApX Machine LearningEngineered with