# Plotting fails on a fresh MacOS install

**URL:** <https://discourse.julialang.org/t/plotting-fails-on-a-fresh-macos-install/70272>\
**Category:** New to Julia\
**Created:** [October 23, 2021, 9:25pm UTC](https://discourse.julialang.org/t/plotting-fails-on-a-fresh-macos-install/70272 "2021-10-23T21:25:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Champagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexandre_champagne/32/19010_2.png) [@Alexandre\_Champagne](https://discourse.julialang.org/u/Alexandre_Champagne)\
**Post date:** [October 23, 2021, 9:25pm UTC](https://discourse.julialang.org/t/plotting-fails-on-a-fresh-macos-install/70272/1 "2021-10-23T21:25:32Z")

</div>

Just installed the latest version of Julia, then tried running a small example found on a forum post in here:

```julia
using Plots; pyplot()
x=range(-2,stop=2,length=100)
y=range(sqrt(2),stop=2,length=100)
f(x,y) = x*y-x-y+1
plot(x,y,f,st=:surface,camera=(-30,30))

```

and it fails with the following errors. Any idea?

````julia
[1] alexandre@Alexandres-MacBook-Pro Desktop ./test.jl
[ Info: Installing matplotlib via the Conda matplotlib package...
[ Info: Running `conda install -y matplotlib` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/alexandre/.julia/conda/3

  added / updated specs:
    - matplotlib

The following packages will be downloaded:

    package | build
    ---------------------------|-----------------
    cycler-0.10.0 | py39hecd8cb5_0 16 KB
    freetype-2.10.4 | ha233b18_0 564 KB
    giflib-5.2.1 | haf1e3a3_0 70 KB
    jpeg-9d | h9ed2024_0 215 KB
    kiwisolver-1.3.1 | py39h23ab428_0 53 KB
    lcms2-2.12 | hf1fd2bf_0 284 KB
    libpng-1.6.37 | ha441bb4_0 262 KB
    libtiff-4.2.0 | h87d7836_0 462 KB
    libwebp-1.2.0 | hacca55c_0 441 KB
    libwebp-base-1.2.0 | h9ed2024_0 389 KB
    lz4-c-1.9.3 | h23ab428_1 140 KB
    matplotlib-3.3.4 | py39hecd8cb5_0 26 KB
    matplotlib-base-3.3.4 | py39h8b3ea08_0 5.1 MB
    olefile-0.46 | pyhd3eb1b0_0 34 KB
    pillow-8.4.0 | py39h98e4679_0 610 KB
    pyparsing-2.4.7 | pyhd3eb1b0_0 59 KB
    python-dateutil-2.8.2 | pyhd3eb1b0_0 233 KB
    tornado-6.1 | py39h9ed2024_0 587 KB
    zstd-1.4.9 | h322a384_0 476 KB
    ------------------------------------------------------------
                                           Total: 9.9 MB

The following NEW packages will be INSTALLED:

  cycler pkgs/main/osx-64::cycler-0.10.0-py39hecd8cb5_0
  freetype pkgs/main/osx-64::freetype-2.10.4-ha233b18_0
  giflib pkgs/main/osx-64::giflib-5.2.1-haf1e3a3_0
  jpeg pkgs/main/osx-64::jpeg-9d-h9ed2024_0
  kiwisolver pkgs/main/osx-64::kiwisolver-1.3.1-py39h23ab428_0
  lcms2 pkgs/main/osx-64::lcms2-2.12-hf1fd2bf_0
  libpng pkgs/main/osx-64::libpng-1.6.37-ha441bb4_0
  libtiff pkgs/main/osx-64::libtiff-4.2.0-h87d7836_0
  libwebp pkgs/main/osx-64::libwebp-1.2.0-hacca55c_0
  libwebp-base pkgs/main/osx-64::libwebp-base-1.2.0-h9ed2024_0
  lz4-c pkgs/main/osx-64::lz4-c-1.9.3-h23ab428_1
  matplotlib pkgs/main/osx-64::matplotlib-3.3.4-py39hecd8cb5_0
  matplotlib-base pkgs/main/osx-64::matplotlib-base-3.3.4-py39h8b3ea08_0
  olefile pkgs/main/noarch::olefile-0.46-pyhd3eb1b0_0
  pillow pkgs/main/osx-64::pillow-8.4.0-py39h98e4679_0
  pyparsing pkgs/main/noarch::pyparsing-2.4.7-pyhd3eb1b0_0
  python-dateutil pkgs/main/noarch::python-dateutil-2.8.2-pyhd3eb1b0_0
  tornado pkgs/main/osx-64::tornado-6.1-py39h9ed2024_0
  zstd pkgs/main/osx-64::zstd-1.4.9-h322a384_0

Downloading and Extracting Packages
giflib-5.2.1 | 70 KB | ##################################################################################################################################################################################################################################### | 100%
matplotlib-base-3.3. | 5.1 MB | ##################################################################################################################################################################################################################################### | 100%
libwebp-1.2.0 | 441 KB | ##################################################################################################################################################################################################################################### | 100%
jpeg-9d | 215 KB | ##################################################################################################################################################################################################################################### | 100%
matplotlib-3.3.4 | 26 KB | ##################################################################################################################################################################################################################################### | 100%
pyparsing-2.4.7 | 59 KB | ##################################################################################################################################################################################################################################### | 100%
libpng-1.6.37 | 262 KB | ##################################################################################################################################################################################################################################### | 100%
lcms2-2.12 | 284 KB | ##################################################################################################################################################################################################################################### | 100%
kiwisolver-1.3.1 | 53 KB | ##################################################################################################################################################################################################################################### | 100%
freetype-2.10.4 | 564 KB | ##################################################################################################################################################################################################################################### | 100%
libwebp-base-1.2.0 | 389 KB | ##################################################################################################################################################################################################################################### | 100%
libtiff-4.2.0 | 462 KB | ##################################################################################################################################################################################################################################### | 100%
lz4-c-1.9.3 | 140 KB | ##################################################################################################################################################################################################################################### | 100%
pillow-8.4.0 | 610 KB | ##################################################################################################################################################################################################################################### | 100%
tornado-6.1 | 587 KB | ##################################################################################################################################################################################################################################### | 100%
python-dateutil-2.8. | 233 KB | ##################################################################################################################################################################################################################################### | 100%
zstd-1.4.9 | 476 KB | ##################################################################################################################################################################################################################################### | 100%
cycler-0.10.0 | 16 KB | ##################################################################################################################################################################################################################################### | 100%
olefile-0.46 | 34 KB | ##################################################################################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
[ Info: Installing pyqt package to avoid buggy tkagg backend.
[ Info: Installing PyQt5 via the Conda pyqt package...
[ Info: Running `conda install -y pyqt` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/alexandre/.julia/conda/3

  added / updated specs:
    - pyqt

The following packages will be downloaded:

    package | build
    ---------------------------|-----------------
    icu-58.2 | h0a44026_3 10.1 MB
    pyqt-5.9.2 | py39h23ab428_6 3.7 MB
    qt-5.9.7 | h468cd18_1 62.0 MB
    sip-4.19.13 | py39h23ab428_0 243 KB
    ------------------------------------------------------------
                                           Total: 76.1 MB

The following NEW packages will be INSTALLED:

  icu pkgs/main/osx-64::icu-58.2-h0a44026_3
  pyqt pkgs/main/osx-64::pyqt-5.9.2-py39h23ab428_6
  qt pkgs/main/osx-64::qt-5.9.7-h468cd18_1
  sip pkgs/main/osx-64::sip-4.19.13-py39h23ab428_0

Downloading and Extracting Packages
pyqt-5.9.2 | 3.7 MB | ##################################################################################################################################################################################################################################### | 100%
sip-4.19.13 | 243 KB | ##################################################################################################################################################################################################################################### | 100%
icu-58.2 | 10.1 MB | ##################################################################################################################################################################################################################################### | 100%
qt-5.9.7 | 62.0 MB | ##################################################################################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
┌ Warning: No working GUI backend found for matplotlib
└ @ PyPlot ~/.julia/packages/PyPlot/XaELc/src/init.jl:165
┌ Warning: You are using Matplotlib 3.3.4, which is no longer
│ officialy supported by the Plots community. To ensure smooth Plots.jl
│ integration update your Matplotlib library to a version >= 3.4.0
│
│ If you have used Conda.jl to install PyPlot (default installation),
│ upgrade your matplotlib via Conda.jl and rebuild the PyPlot.
│
│ If you are not sure, here are the default instructions:
│
│ In Julia REPL:
│ ```
│ import Pkg;
│ Pkg.add("Conda")
│ import Conda
│ Conda.update()
│ Pkg.build("PyPlot")
│ ```
│
└ @ Plots ~/.julia/packages/Plots/vFFCj/src/backends/pyplot.jl:29
ERROR: LoadError: PyError ($(Expr(:escape, :(ccall(#= /Users/alexandre/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'AttributeError'>
AttributeError("'Text' object has no property 'math_fontfamily'")
  File "/Users/alexandre/.julia/conda/3/lib/python3.9/site-packages/matplotlib/colorbar.py", line 761, in set_label
    self._set_label()
  File "/Users/alexandre/.julia/conda/3/lib/python3.9/site-packages/matplotlib/colorbar.py", line 731, in _set_label
    self.ax.set_ylabel(self._label, **self._labelkw)
  File "/Users/alexandre/.julia/conda/3/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 300, in set_ylabel
    return self.yaxis.set_label_text(ylabel, fontdict, **kwargs)
  File "/Users/alexandre/.julia/conda/3/lib/python3.9/site-packages/matplotlib/axis.py", line 1566, in set_label_text
    self.label.update(kwargs)
  File "/Users/alexandre/.julia/conda/3/lib/python3.9/site-packages/matplotlib/text.py", line 179, in update
    super().update(kwargs)
  File "/Users/alexandre/.julia/conda/3/lib/python3.9/site-packages/matplotlib/artist.py", line 996, in update
    raise AttributeError(f"{type(self). __name__!r} object "

Stacktrace:
  [1] pyerr_check
    @ ~/.julia/packages/PyCall/BD546/src/exception.jl:62 [inlined]
  [2] pyerr_check
    @ ~/.julia/packages/PyCall/BD546/src/exception.jl:66 [inlined]
  [3] _handle_error(msg::String)
    @ PyCall ~/.julia/packages/PyCall/BD546/src/exception.jl:83
  [4] macro expansion
    @ ~/.julia/packages/PyCall/BD546/src/exception.jl:97 [inlined]
  [5] #107
    @ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 [inlined]
  [6] disable_sigint
    @ ./c.jl:458 [inlined]
  [7] __pycall!
    @ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:42 [inlined]
  [8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{String}, nargs::Int64, kw::PyCall.PyObject)
    @ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:29
  [9] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{String}, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:size, :family, :math_fontfamily, :color), Tuple{Int64, String, String, NTuple{4, FixedPointNumbers.N0f8}}}})
    @ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:11
 [10] #_#114
    @ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:86 [inlined]
 [11] _before_layout_calcs(plt::Plots.Plot{Plots.PyPlotBackend})
    @ Plots ~/.julia/packages/Plots/vFFCj/src/backends/pyplot.jl:1155
 [12] prepare_output(plt::Plots.Plot{Plots.PyPlotBackend})
    @ Plots ~/.julia/packages/Plots/vFFCj/src/plot.jl:217
 [13] show
    @ ~/.julia/packages/Plots/vFFCj/src/output.jl:212 [inlined]
 [14] pdf(plt::Plots.Plot{Plots.PyPlotBackend}, fn::String)
    @ Plots ~/.julia/packages/Plots/vFFCj/src/output.jl:23
 [15] savefig(plt::Plots.Plot{Plots.PyPlotBackend}, fn::String)
    @ Plots ~/.julia/packages/Plots/vFFCj/src/output.jl:123
 [16] savefig(fn::String)
    @ Plots ~/.julia/packages/Plots/vFFCj/src/output.jl:128
 [17] top-level scope
    @ ~/Desktop/test.jl:9
in expression starting at /Users/alexandre/Desktop/test.jl:9
[1] alexandre@Alexandres-MacBook-Pro Desktop

````

---

<div class="post-metadata">

**Author:** ![Alexandre\_Champagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexandre_champagne/32/19010_2.png) [@Alexandre\_Champagne](https://discourse.julialang.org/u/Alexandre_Champagne)\
**Post date:** [October 23, 2021, 9:30pm UTC](https://discourse.julialang.org/t/plotting-fails-on-a-fresh-macos-install/70272/2 "2021-10-23T21:30:13Z")

</div>

For others having the same issue, found a solution:

In Julia REPL,

```julia
import Pkg;
Pkg.add("Conda")
import Conda
Conda.update()
Pkg.build("PyPlot")

```

No idea why was that necessary but the code now works. Though I’m still getting a warning, no idea if there’s any consequence.

```julia
[1] alexandre@Alexandres-MacBook-Pro Desktop ./test.jl
[ Info: Installing pyqt package to avoid buggy tkagg backend.
┌ Warning: No working GUI backend found for matplotlib
└ @ PyPlot ~/.julia/packages/PyPlot/XaELc/src/init.jl:165

```

---

<div class="post-metadata">

**Author:** ![diadora77](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diadora77/32/220469_2.png) [@diadora77](https://discourse.julialang.org/u/diadora77)\
**Post date:** [November 29, 2021, 11:05pm UTC](https://discourse.julialang.org/t/plotting-fails-on-a-fresh-macos-install/70272/3 "2021-11-29T23:05:35Z")

</div>

I was having the same problem and getting the same warning about using Matplotlib 3.3.4. Fix required re-building PyCall _after_ setting ENV[“PYTHON”]=“… to appropriate python or venv…” that has an updated or appropriate matplotlib version. After that, PyPlot was fine. PyPlot uses PyCall so re-building PyPlot did not help in that case.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [November 30, 2021, 1:12am UTC](https://discourse.julialang.org/t/plotting-fails-on-a-fresh-macos-install/70272/4 "2021-11-30T01:12:24Z")

</div>

> [@Alexandre\_Champagne](#):
>
> `You are using Matplotlib 3.3.4, which is no longer`

Conda/pip doesn’t try to fetch the newest pkg, the strategy is “whatever works”. And it looks like a manual `Conda.update()` from Julia’s side solves the issue.
