Travis CI fails to import PyPlot



Hi all,

I am trying to prepare the 0.4 release of my package, Spectra.jl. I try to run the tests in Travis CI (Linux and OSX), but I get a weird error regarding PyPlot.

It seems that, when Travis CI try running the tests, it tries importing PyPlot during Spectra pre-compilation but can’t find it.

But PyPlot is in my REQUIRE file so it should be installed… Following a previous post on a similar subject, I setup my Travis yaml file as shown below, but still fails…

Thanks in advance for any help!

Here is the travis yaml file I uses:

# Documentation:
language: julia
  - linux
  - osx
  - 0.6
#  - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get -qq update; fi
    - gfortran
  email: false
 - PYTHON=""
  - if [ $TRAVIS_OS_NAME = osx ]; then brew install gcc; fi
  - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
  - julia -e 'Pkg.clone(pwd())'
  - julia -e '"Spectra"); Pkg.test("Spectra")'

  - julia -e 'Pkg.add("Documenter")'
  - julia -e 'cd(Pkg.dir("Spectra")); include(joinpath("docs", "make.jl"))'

And here is the error shown during test initialisation on Travis CI:

INFO: Testing Spectra
INFO: Installing matplotlib via the Conda matplotlib package...
Solving environment: ...working... done
## Package Plan ##
  environment location: /home/travis/.julia/v0.6/Conda/deps/usr
  added / updated specs: 
    - matplotlib
The following packages will be downloaded:
    package                    |            build
    backports.functools_lru_cache-1.4|   py27he8db605_1           9 KB
    pyparsing-2.2.0            |   py27hf1513f8_1          93 KB
    pytz-2017.3                |   py27h001bace_0         210 KB
    cycler-0.10.0              |   py27hc7354d3_0          13 KB
    matplotlib-2.1.2           |   py27h0e671d2_0         6.6 MB
    subprocess32-3.2.7         |   py27h373dbce_0          40 KB
                                           Total:         6.9 MB
The following NEW packages will be INSTALLED:
    backports.functools_lru_cache: 1.4-py27he8db605_1   
    cycler:                        0.10.0-py27hc7354d3_0
    matplotlib:                    2.1.2-py27h0e671d2_0 
    pyparsing:                     2.2.0-py27hf1513f8_1 
    pytz:                          2017.3-py27h001bace_0
    subprocess32:                  3.2.7-py27h373dbce_0 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
WARNING: No working GUI backend found for matplotlib
ERROR: LoadError: InitError: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)

The Python package matplotlib.pyplot could not be found by pyimport. Usually this means
that you did not install matplotlib.pyplot in the Python version being used by PyCall.
PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the matplotlib.pyplot module, you can
use `pyimport_conda("matplotlib.pyplot", PKG)`, where PKG is the Anaconda
package the contains the module matplotlib.pyplot, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).
Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run"PyCall"), and re-launch Julia.