# PyPlot on macOS Monterey with M1

**URL:** <https://discourse.julialang.org/t/pyplot-on-macos-monterey-with-m1/72185>\
**Category:** Visualization\
**Tags:** mac-m1\
**Created:** [November 27, 2021, 11:53pm UTC](https://discourse.julialang.org/t/pyplot-on-macos-monterey-with-m1/72185 "2021-11-27T23:53:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![George9000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/george9000/32/23619_2.png) [@George9000](https://discourse.julialang.org/u/George9000)\
**Post date:** [November 27, 2021, 11:53pm UTC](https://discourse.julialang.org/t/pyplot-on-macos-monterey-with-m1/72185/1 "2021-11-27T23:53:56Z")

</div>

While trying out [Fatou.jl](https://crucialflow.com/Fatou.jl/), I had difficulty getting PyPlot to work on an M1 Mac. Here is the environement and steps that got things working.

## Python

I am not using Conda. I did follow directions [here](https://github.com/rybodiddly/Poetry-Pyenv-Homebrew-Numpy-TensorFlow-on-Apple-Silicon-M1) to set things up on the M1 with pyenv, followed by `brew install python` (non-Rosetta), pipx, and Poetry.

> **My .zshrc**
>
> ```julia-auto
> export PATH="/opt/homebrew/bin:/Users/foo/Library/Python/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:$PATH"
> export SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
> 
> export PATH="$HOME/.pyenv/bin:$PATH"
> if command -v pyenv 1>/dev/null 2>&1; then
> eval "$(pyenv init -)"
> fi
> 
> alias python="python3"
> 
> export PATH="~/.local/bin:$PATH"
> 
> export PIP_REQUIRE_VIRTUALENV=true
> # escape hatches to override above stipulation;
> # had to use gpip3 below to install numpy and matplotlib
> gpip(){
> PIP_REQUIRE_VIRTUALENV="" pip "$@"
> }
> 
> gpip3(){
> PIP_REQUIRE_VIRTUALENV="" pip3 "$@"
> }
> 
> export MPLBACKEND=qt5agg ## this is crucial for Julia PyPlot package build
> 
> ```

```julia-auto
gpip3 install numpy ## see .zshrc
gpip3 install matplotlib

brew install pyqt@5
## please see also .zshrc MPLBACKEND variable

```

## Julia

In the project, directory…

```julia-auto
julia > ENV["PYTHON"]="python3"

] add PyCall, PyPlot
] build PyCall, PyPlot

```

After this, all was well with PyPlot on the M1.
