Get names and versions of loaded modules

Is there a way to get the names and version numbers of the currently loaded modules in a Julia session?

You can get the modules with Base.loaded_modules. Julia itself doesn’t have a concept of versions on modules so that doesn’t exist.

3 Likes

@uwechsler The modules have not version number, I think you want to say package. With the name of a loaded package, you can get the version number with https://github.com/KlausC/PkgVersion.jl.

2 Likes

Thank you a lot!

@kristoffer.carlsson Is it “save” to use Base.loaded_modules with respect to future Julia 1.x releases? From the answer to this question Using an already-loaded module in 0.7 - #6 by StefanKarpinski I assumed I should avoid using it.
@dmolina you are right, I was talking about packages. This package helps already a lot. I want to figure out what pacakges (and versions) are loaded in a custom system image. At leaste, for my own packages I am able to do that now, thanks.

It depends what you mean with safe. It is an internal variable so it is possible it could change in the future, yes. There isn’t really any other way to do it right now though.

3 Likes

Here’s a one-liner for finding the version number of a loaded module, e.g. HTTP:

using Pkg
using HTTP

Pkg.dependencies(x -> x.version, findfirst(p -> p == HTTP, Base.loaded_modules).uuid)

There is now also pkgversion.

1 Like