JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
478 stars 88 forks source link

`ImportError` on `using PyPlot` #338

Closed ararslan closed 6 years ago

ararslan commented 6 years ago

I'm getting the following error on Elementary OS (essentially Ubuntu 16.04.1):

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> ENV["PYTHON"] = ""
""

julia> Pkg.build("PyCall")
INFO: Building Conda
INFO: Building PyCall
INFO: Using the Python distribution in the Conda package by default.
To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").
Solving environment: done

# All requested packages already installed.

INFO: PyCall is using /home/alex/.julia/v0.6/Conda/deps/usr/bin/python (Python 2.7.14) at /home/alex/.julia/v0.6/Conda/deps/usr/bin/python, libpython = /home/alex/.julia/v0.6/Conda/deps/usr/lib/libpython2.7
INFO: /home/alex/.julia/v0.6/PyCall/deps/deps.jl has not changed
INFO: /home/alex/.julia/v0.6/PyCall/deps/PYTHON has not changed

julia> using Conda

julia> Conda.add("matplotlib")
Solving environment: done

# All requested packages already installed.

julia> Pkg.build("PyPlot")
INFO: Building Conda
INFO: Building PyCall
INFO: Using the Python distribution in the Conda package by default.
To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").
Solving environment: done

# All requested packages already installed.

INFO: PyCall is using /home/alex/.julia/v0.6/Conda/deps/usr/bin/python (Python 2.7.14) at /home/alex/.julia/v0.6/Conda/deps/usr/bin/python, libpython = /home/alex/.julia/v0.6/Conda/deps/usr/lib/libpython2.7
INFO: /home/alex/.julia/v0.6/PyCall/deps/deps.jl has not changed
INFO: /home/alex/.julia/v0.6/PyCall/deps/PYTHON has not changed

julia> using PyPlot
INFO: Recompiling stale cache file /home/alex/.julia/lib/v0.6/PyPlot.ji for module PyPlot.
sys:1: UserWarning: 
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

The backend was *originally* set to u'Qt5Agg' by the following code:
  File "/home/alex/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
    line for line in traceback.format_stack()

WARNING: No working GUI backend found for matplotlib
ERROR: 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 Pkg.build("PyCall"), and re-launch Julia.

) <type 'exceptions.ImportError'>
ImportError("/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/alex/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/../../.././libpng16.so.16)",)
  File "/home/alex/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "/home/alex/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/colorbar.py", line 36, in <module>
    import matplotlib.contour as contour
  File "/home/alex/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/contour.py", line 21, in <module>
    import matplotlib.font_manager as font_manager
  File "/home/alex/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/font_manager.py", line 58, in <module>
    from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir

Stacktrace:
 [1] pyerr_check at /home/alex/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
 [2] pyerr_check at /home/alex/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
 [3] macro expansion at /home/alex/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
 [4] pyimport(::String) at /home/alex/.julia/v0.6/PyCall/src/PyCall.jl:374
 [5] __init__() at /home/alex/.julia/v0.6/PyPlot/src/init.jl:184
 [6] _include_from_serialized(::String) at ./loading.jl:157
 [7] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:200
 [8] _require(::Symbol) at ./loading.jl:464
 [9] require(::Symbol) at ./loading.jl:405
during initialization of module PyPlot

PyPlot 2.3.2, PyCall 1.15.0, Conda 0.7.1. Also happens with PyPlot 2.3.1.

stevengj commented 6 years ago

Duplicate of #151. If you can find a better workaround than the LD_PRELOAD trick discussed there, it would be much appreciated.

ararslan commented 6 years ago

Ah sorry, I didn't see that one. Thanks.