# How to use Pkg.dependencies() instead of Pkg.installed()

**URL:** <https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416>\
**Category:** General Usage\
**Tags:** package, package-manager\
**Created:** [March 24, 2020, 5:11am UTC](https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416 "2020-03-24T05:11:54Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![Ralf\_Dietrich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralf_dietrich/32/5643_2.png) [@Ralf\_Dietrich](https://discourse.julialang.org/u/Ralf_Dietrich)\
**Post date:** [February 13, 2023, 9:50am UTC](https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416/19 "2023-02-13T09:50:19Z")

</div>

This code of mine works wonderfully and hopefully solves almost all the issues raised here:

```julia
# Make sure all needed Pkg's are ready to go
neededPackages = [:Gtk4, :Cairo] 
using Pkg;
for neededpackage in neededPackages
    (String(neededpackage) in keys(Pkg.project().dependencies)) || Pkg.add(String(neededpackage))
    @eval using $neededpackage
end

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416)._
