# Matplotlib dependency for Documenter.jl in Github Actions

**URL:** <https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597>\
**Category:** Tooling\
**Created:** [December 10, 2020, 9:16am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597 "2020-12-10T09:16:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 10, 2020, 9:16am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/1 "2020-12-10T09:16:47Z")

</div>

I just wrote a small part of the documentation, that uses `PyPlots.jl` to render a plot (I am actually documenting a `PlotRecipe`. What is the easiest way to add the `matplotlib` and `python` to the documenter Github Action?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [December 10, 2020, 11:27am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/2 "2020-12-10T11:27:35Z")

</div>

I may not be understanding your precise question, but assuming `docs/Project.toml` exists I think you could just add `PyPlot` as one of the `[deps]`. I doubt the workflow script would need changing.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 10, 2020, 11:35am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/3 "2020-12-10T11:35:01Z")

</div>

Thanks for the answer. I have `PyPlot` in my `[deps]` and all is working fine locally. But on my machine here, I have python and matplotlib installed for sure.

On the CI (GitHubActions, i.e. using a `.github/workflows/documenter.yml`) this seems to be missing.

---

<div class="post-metadata">

**Author:** ![sostock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sostock/32/5546_2.png) [@sostock](https://discourse.julialang.org/u/sostock)\
**Post date:** [December 10, 2020, 11:35am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/4 "2020-12-10T11:35:14Z")

</div>

PyPlot will install its own python and matplotlib (via Conda.jl) if the environment variable `PYTHON` is empty (cf. [the PyPlot.jl readme](https://github.com/JuliaPy/PyPlot.jl#automated-matplotlib-installation)). I think doing that would be the easiest way.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 10, 2020, 11:39am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/5 "2020-12-10T11:39:03Z")

</div>

Are you sure that works within a CI? The error message I get is

[https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check\_run\_id=1529534899#step:4:363](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check_run_id=1529534899#step:4:363)

but interestingly, while I had hoped I got at least Gtk to work, that also does not work on CI

[https://github.com/JuliaManifolds/Manifolds.jl/runs/1529534673?check\_suite\_focus=true#step:5:376](https://github.com/JuliaManifolds/Manifolds.jl/runs/1529534673?check_suite_focus=true#step:5:376)

---

<div class="post-metadata">

**Author:** ![sostock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sostock/32/5546_2.png) [@sostock](https://discourse.julialang.org/u/sostock)\
**Post date:** [December 10, 2020, 11:53am UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/6 "2020-12-10T11:53:57Z")

</div>

I’m not sure that it works, I haven’t tried it myself.

However, I don’t see the environment variable `PYTHON` being set to `""` anywhere in your workflow. The error message says that the python version at `/usr/bin/python3` is used, so I would assume that `PYTHON` is set to `/usr/bin/python3`.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 10, 2020, 12:00pm UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/7 "2020-12-10T12:00:31Z")

</div>

Thanks for investigating my log and checking. I will try to set it using `env` in the YAML then.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 10, 2020, 2:34pm UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/8 "2020-12-10T14:34:37Z")

</div>

Independent of whether I try to set

```julia
env:
    PYTHON: ""

```

(See [https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check\_run\_id=1530835584#step:4:348](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check_run_id=1530835584#step:4:348) for the error and [https://github.com/JuliaManifolds/Manifolds.jl/pull/245/commits/21c3ba486b95628bc7005dbc9d06749fa4fec100](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/commits/21c3ba486b95628bc7005dbc9d06749fa4fec100) for how I tried to set it)  
in the yaml or

```julia
ENV["PYTHON"] = ""

```

within Julia, the error persists and it’s still looking in the CIs VM in `usr/local/bin` for a `python`, see [https://github.com/JuliaManifolds/Manifolds.jl/pull/245/commits/f5a2a14184349dff014cb2a76c2453558f1d2780](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/commits/f5a2a14184349dff014cb2a76c2453558f1d2780) for the commit and [https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check\_run\_id=1530835584#step:4:355](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check_run_id=1530835584#step:4:355) for the error).

So where actually do I have to set that environment variable? Or do I have to add python to the action? If so, how?

---

<div class="post-metadata">

**Author:** ![sostock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sostock/32/5546_2.png) [@sostock](https://discourse.julialang.org/u/sostock)\
**Post date:** [December 10, 2020, 3:17pm UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/9 "2020-12-10T15:17:24Z")

</div>

> [@kellertuer](#):
>
> ```julia-auto
> env:
> PYTHON: ""
> 
> ```
> 
> (See [Plotting Recipe for data on S2 and H2 by kellertuer · Pull Request #245 · JuliaManifolds/Manifolds.jl · GitHub](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check_run_id=1530835584#step:4:348) for the error and [Plotting Recipe for data on S2 and H2 by kellertuer · Pull Request #245 · JuliaManifolds/Manifolds.jl · GitHub](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/commits/21c3ba486b95628bc7005dbc9d06749fa4fec100) for how I tried to set it)

You have to set the environment variable at the step where the package is built. In your `documenter.yml`, that is one step later (in `julia-actions/julia-docdeploy@v1` instead of `julia-actions/setup-julia@latest`).

> [@kellertuer](#):
>
> ```julia-auto
> ENV["PYTHON"] = ""
> 
> ```
> 
> within Julia, the error persists and it’s still looking in the CIs VM in `usr/local/bin` for a `python` , see [Plotting Recipe for data on S2 and H2 by kellertuer · Pull Request #245 · JuliaManifolds/Manifolds.jl · GitHub](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/commits/f5a2a14184349dff014cb2a76c2453558f1d2780) for the commit and [Plotting Recipe for data on S2 and H2 by kellertuer · Pull Request #245 · JuliaManifolds/Manifolds.jl · GitHub](https://github.com/JuliaManifolds/Manifolds.jl/pull/245/checks?check_run_id=1530835584#step:4:355) for the error).

Setting the environment variable in the `make.jl` file is also not helpful, the package is already built when this is executed.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 10, 2020, 4:10pm UTC](https://discourse.julialang.org/t/matplotlib-dependency-for-documenter-jl-in-github-actions/51597/10 "2020-12-10T16:10:29Z")

</div>

Adding it to the `docdeploy` stage seems to have worked, since the images [Sphere · Manifolds.jl](https://juliamanifolds.github.io/Manifolds.jl/previews/PR245/manifolds/sphere.html#Visualization-on-Sphere%7B2,%E2%84%9D%7D) are available in the PR. Thanks for the help. I think that way I can now also try to fix the tests and GKS accordingly.

Thanks!
