# TravisCI issue for a Julia package using PyPlot.jl

**URL:** https://discourse.julialang.org/t/travisci-issue-for-a-julia-package-using-pyplot-jl/95079
**Category:** General Usage
**Tags:** question, travis, github, travis-ci, github-actions
**Created:** [February 23, 2023, 2:12pm UTC](https://discourse.julialang.org/t/travisci-issue-for-a-julia-package-using-pyplot-jl/95079 "2023-02-23T14:12:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kazuakiyama](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kazuakiyama/32/47128_2.png) [@kazuakiyama](https://discourse.julialang.org/u/kazuakiyama)
#### Post date: [February 23, 2023, 2:12pm UTC](https://discourse.julialang.org/t/travisci-issue-for-a-julia-package-using-pyplot-jl/95079/1 "2023-02-23T14:12:05Z")

</div>

Hi, I’m developing a Julia astronomy package on GitHub, and have a question regarding an issue in TravisCI’s github action for a package using PyPlot.jl. My package uses PyPlot.jl for visualizations of data.

I’ve been facing the following errors in GitHub Actions for Travis CI. You can find the complete set of logs [here](https://github.com/EHTJulia/EHTImages.jl/actions/runs/4246381466/jobs/7398155875). In short, PyCall can’t load matplotlib when PyPlot.jl is being precompiled perhaps due to an issue regarding the internal python’s path. This happens only ubuntu-latest regardless of Julia versions while it works okay for macos-latest. I would really appreciate it if you know how to fix this issue.

```julia
ERROR: LoadError: InitError: PyError (PyImport_ImportModule

The Python package matplotlib could not be imported by pyimport. Usually this means
that you did not install matplotlib in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

/usr/bin/python3

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the matplotlib module.

One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.

Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia. As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the matplotlib module, you can use `pyimport_conda("matplotlib", PKG)`,
where PKG is the Anaconda package that contains the module matplotlib,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'matplotlib'")

```

---

<div class="post-metadata">

### Author: ![kazuakiyama](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kazuakiyama/32/47128_2.png) [@kazuakiyama](https://discourse.julialang.org/u/kazuakiyama)
#### Post date: [February 23, 2023, 4:03pm UTC](https://discourse.julialang.org/t/travisci-issue-for-a-julia-package-using-pyplot-jl/95079/2 "2023-02-23T16:03:29Z")

</div>

I was able to figure it out. Apparently, I just needed to add the following prescription in make.jl for docs and runtests.jl for test. This needs to add Pkg and PyPlot in Project.toml of the main repository and also of the documentation. Let me know if you have a better solution.

```julia
using Pkg
ENV["PYTHON"]=""
Pkg.build("PyCall")
using PyPlot

```
