# How to see all installed packages? + a few other \`Pkg\` related questions

**URL:** <https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231>\
**Category:** New to Julia\
**Created:** [December 31, 2016, 7:01pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231 "2016-12-31T19:01:15Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 14, 2023, 9:01pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/22 "2023-01-14T21:01:42Z")

</div>

You can explore stuff like this if you like:

```julia
using Pkg

p = Pkg.project()
d = Pkg.dependencies()

for k in p.dependencies
    pk = d[last(k)]
    println(pk.name, " ", pk.version)
end

```

Not sure if that’s an “official” way or not.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 14, 2023, 9:11pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/23 "2023-01-14T21:11:39Z")

</div>

> [@cormullion](#):
>
> Not sure if that’s an “official” way or not.

`Pkg.dependencies()` is official but not `Pkg.project` but everything is inside `Pkg.dependencies()` anyway so you don’t really need thatl

---

<div class="post-metadata">

**Author:** ![austin-putz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/austin-putz/32/2583_2.png) [@austin-putz](https://discourse.julialang.org/u/austin-putz)\
**Post date:** [January 14, 2023, 9:23pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/24 "2023-01-14T21:23:01Z")

</div>

@kristoffer.carlsson thank you very much, but when I do `Pkg.dependencies()` I get packages I have not installed on the current version of Julia (1.8.5 just today). It lists packages I’ve installed in the past. I don’t know how to write an up to date replacement for the following. Can you help? Or maybe there is a link somewhere showing how to do this?

```julia
# Check if BenchmarkTools is installed
if !("BenchmarkTools" in keys(Pkg.installed()))
Pkg.add("BenchmarkTools")
end

```

---

<div class="post-metadata">

**Author:** ![austin-putz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/austin-putz/32/2583_2.png) [@austin-putz](https://discourse.julialang.org/u/austin-putz)\
**Post date:** [January 14, 2023, 9:24pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/25 "2023-01-14T21:24:27Z")

</div>

Oh nvm, looks like all I needed as to replace installed with dependencies… sorry.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 14, 2023, 9:44pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/26 "2023-01-14T21:44:47Z")

</div>

Note that `Pkg.dependencies()` have UUIDs as their keys. But you can do your BenchmarkTools query like

```julia
julia> any(x -> x.name == "BenchmarkTools", values(Pkg.dependencies()))
true

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 14, 2023, 9:56pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/27 "2023-01-14T21:56:17Z")

</div>

In other words: depreciating Pkg.installed() makes our code more complicated and harder to read. Why was this done in the first place?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 14, 2023, 10:01pm UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/28 "2023-01-14T22:01:15Z")

</div>

> [@ufechner7](#):
>
> In other words: depreciating Pkg.dependancies() makes our code more complicated and harder to read. Why was this done in the first place?

You mean deprecating `Pkg.installed`? The reason was that you can have multiple packages with the same name in an environment now, so having a dictionary with the package names as the keys means that you could have collisions. The UUIDs are unique so that’s what was chosen as the dict key.

If we restricted the returned packages as those that are in the project then the names would be unique though. So there could be a `Pkg.direct_dependencies()` or something with names as the key to the dictionary.

And for the record, I don’t think `Pkg.dependencies()` is super elegant, it might be better just to parse the `TOML` file.

```julia
julia> using TOML

julia> d = TOML.parsefile(Base.active_project());

julia> haskey(d["deps"], "BenchmarkTools")
true

```

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 27, 2023, 2:17am UTC](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231/29 "2023-01-27T02:17:42Z")

</div>

> [@ufechner7](#):
>
> Why was this done in the first place?

Because I’m a big meanie and I wanted to make peoples lives more difficult.

Just kidding of course. But you can assume that if something was deprecated, there was a good reason for it. In this case: the old `Pkg.installed()` function doesn’t really make sense in the world of Pkg3 (i.e. post 1.0) where packages are no longer uniquely identified by name.

[Previous page](https://discourse.julialang.org/t/how-to-see-all-installed-packages-a-few-other-pkg-related-questions/1231.md?page=1)
