PyPlot not working properly



I am using Julia 0.6.0 in Atom and I have installed Plots.jl and PyPlot.jl, so I tried the codes below:

function fn1(x)                
  y = (x-1.1)^2 - 0.5                
  return y

x = collect(-3:6/99:6) 

title!("My Results")
ylabel!("my output value")

I got the error message:

PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)

The Python package mpl_toolkits.mplot3d could not be found by pyimport. Usually this means
that you did not install mpl_toolkits.mplot3d 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 mpl_toolkits.mplot3d module, you can
use `pyimport_conda("mpl_toolkits.mplot3d", PKG)`, where PKG is the Anaconda
package the contains the module mpl_toolkits.mplot3d, 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.

) <type 'exceptions.ImportError'>
ImportError("/usr/bin/../lib64/../lib64/ version `ZLIB_1.2.9' not found (required by /home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/../../.././",)
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/mpl_toolkits/mplot3d/", line 6, in <module>
    from .axes3d import Axes3D
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/mpl_toolkits/mplot3d/", line 24, in <module>
    import matplotlib.axes as maxes
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/", line 4, in <module>
    from ._subplots import *
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/", line 10, in <module>
    from matplotlib.axes._axes import Axes
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/", line 22, in <module>
    import matplotlib.contour as mcontour
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/", line 21, in <module>
    import matplotlib.font_manager as font_manager
  File "/home/Yifan/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/", line 58, in <module>
    from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir

pyerr_check at exception.jl:56 [inlined]
pyerr_check at exception.jl:61 [inlined]
macro expansion at exception.jl:81 [inlined]
pyimport(::String) at PyCall.jl:399
_initialize_backend(::Plots.PyPlotBackend) at pyplot.jl:68
backend() at backends.jl:185
Plots.Plot() at types.jl:81
#plot#145(::Array{Any,1}, ::Function, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at plot.jl:54
(::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::Array{Float64,1}, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at <missing>:0
(::Atom.##63#66)() at eval.jl:104
withpath(::Atom.##63#66, ::Void) at utils.jl:30
withpath(::Function, ::Void) at eval.jl:38
macro expansion at eval.jl:103 [inlined]
(::Atom.##62#65{Dict{String,Any}})() at task.jl:80


Does calling

LD_PRELOAD=${HOME}/.julia/v0.6/Conda/deps/usr/lib/ julia

as indicated in work for you?


This is an aside, but this code:

can be written more succinctly as

plot(x->(x-1.1)^2-0.5, -3, 6, color=:red,linewidth=2,label=“fn1()”)