JuliaPy / PyPlot.jl

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

Cannot import PyPlot #343

Closed Aanai closed 6 years ago

Aanai commented 6 years ago

This is the error I get when I run "using PyPlot". I am using Ubuntu 16.04 and had Python 2.7.12 installed. I installed anaconda hoping that would help solve the problem but it didn't. Now "python -V" gives me "Python 2.7.14 :: Anaconda, Inc."

When I run Conda.list() inside julia, I do get "matplotlib" and "basemap" (includes mpl_toolkits, I think) and when I run "conda list" outside julia (bash?) I get a longer list which also contains "matplotlib" and "basemap".

Changing the environment to the python executable outside Julia doesn't fix the problem.

julia> using PyPlot
INFO: Recompiling stale cache file /home/user/.julia/lib/v0.6/ColorTypes.ji for module ColorTypes.
INFO: Recompiling stale cache file /home/user/.julia/lib/v0.6/Colors.ji for module Colors.
INFO: Recompiling stale cache file /home/user/.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/user/.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/user/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/../../.././libpng16.so.16)",)
  File "/home/user/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "/home/user/.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/user/.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/user/.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/user/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
 [2] pyerr_check at /home/user/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
 [3] macro expansion at /home/user/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
 [4] pyimport(::String) at /home/user/.julia/v0.6/PyCall/src/PyCall.jl:399
 [5] __init__() at /home/user/.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