# Error building MPI---ERROR: LoadError: libmpi could not be found

**URL:** <https://discourse.julialang.org/t/error-building-mpi-error-loaderror-libmpi-could-not-be-found/65016>\
**Category:** General Usage\
**Tags:** package, mpi\
**Created:** [July 21, 2021, 5:21am UTC](https://discourse.julialang.org/t/error-building-mpi-error-loaderror-libmpi-could-not-be-found/65016 "2021-07-21T05:21:11Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![christmas\_jones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christmas_jones/32/29540_2.png) [@christmas\_jones](https://discourse.julialang.org/u/christmas_jones)\
**Post date:** [July 20, 2022, 5:54pm UTC](https://discourse.julialang.org/t/error-building-mpi-error-loaderror-libmpi-could-not-be-found/65016/4 "2022-07-20T17:54:40Z")

</div>

Thanks for this, this was bugging me for ages (on Mac M1, julia 1.8). I found I also had to set the library path for it to not throw the error about libmpi. For me, I had MPI installed via homebrew, and the following steps worked (in case anyone else had similar issues):

```julia
export JULIA_MPI_PATH=/opt/homebrew/Cellar/open-mpi/4.1.4
export JULIA_MPI_LIBRARY=/opt/homebrew/Cellar/open-mpi/4.1.4/lib/libmpi
julia -e 'ENV["JULIA_MPI_BINARY"]="system"; using Pkg; Pkg.build("MPI"; verbose=true)'

```

This resulted in the MPI.toml file (you can find in .julia/prefs) being (automatically) set up as:

```julia
library = "/opt/homebrew/Cellar/open-mpi/4.1.4/lib/libmpi"
binary = "system"
path = "/opt/homebrew/Cellar/open-mpi/4.1.4"

```

and I was able to run mpiexec/mpirun as expected with julia.

Also note, if I did the above, but with e.g. “/opt/homebrew/lib” it did not work, even though there are libmpi.dylib files there. The issue, I believe, is these are aliases, and if you do ‘show original’ it takes you to the path I used above.

---

_[View the full topic](https://discourse.julialang.org/t/error-building-mpi-error-loaderror-libmpi-could-not-be-found/65016)._
