# How to test if package is installed

**URL:** <https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 4, 2017, 6:18am UTC](https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508 "2017-05-04T06:18:47Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![truedichotomy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/truedichotomy/32/11076_2.png) [@truedichotomy](https://discourse.julialang.org/u/truedichotomy)\
**Post date:** [December 2, 2021, 6:32am UTC](https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508/21 "2021-12-02T06:32:21Z")

</div>

I find myself needing to test whether a package is installed with the release of Julia v1.7 running on Mac with Apple Silicon. One of the packages I normally use is not yet compatible with Apple Silicon, so for now I’m using the python version via PyCall. I’d like my code to handle both scenarios so I need to determine whether the Julia version of the package is installed or not. If not, use the python version. Maybe this is a short term issue but I support having Pkg.installed retained in Pkg.

---

<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:** [April 10, 2022, 10:25am UTC](https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508/22 "2022-04-10T10:25:08Z")

</div>

For me, I can avoid any warning by using

```julia
"somepackage" ∈ keys(Pkg.project().dependencies)

```

instead of:

> [@Tamas\_Papp](#):
>
> `"somepackage" ∈ keys(Pkg.installed())`

In this way I avoid the depreciation warning I get otherwise. 🙂

---

<div class="post-metadata">

**Author:** ![DWSchulze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dwschulze/32/35968_2.png) [@DWSchulze](https://discourse.julialang.org/u/DWSchulze)\
**Post date:** [May 14, 2022, 11:24pm UTC](https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508/23 "2022-05-14T23:24:56Z")

</div>

That no longer works:

```julia
isinstalled(Flux) = pkg != "METADATA" && pkg != "REQUIRE" && pkg[1] != '.' && Pkg.cd(isdir, pkg)

isinstalled (generic function with 1 method)

```

---

<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, 10:00am UTC](https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508/24 "2023-02-13T10:00:07Z")

</div>

This here helps me alot: [How to use Pkg.dependencies() instead of Pkg.installed() - #19 by Ralf\_Dietrich](https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416/19)

[Previous page](https://discourse.julialang.org/t/how-to-test-if-package-is-installed/3508.md?page=1)
