Struggling with Julia configuration


#1

Hello,
recently I’ve installed Julia and python on my PC (Ubuntu 16.04 LTS) and tried to give it a try. Everything works good until I want to use plotting. Here is a piece of code I’d like to compile:

Pkg.add("PyPlot")
using Plots
pyplot()
plot(rand(10))

I used juliabox to check if it works and it does w/o any issues. My output for command julia exp.jl looks like this:

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/bartosz/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
    line for line in traceback.format_stack()


INFO: Nothing to be done
WARNING: No working GUI backend found for matplotlib
WARNING: Couldn't initialize pyplot.  (might need to install it?)
ERROR: LoadError: InitError: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError("/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/bartosz/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/../../.././libpng16.so.16)",)
  File "/home/bartosz/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/home/bartosz/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/colorbar.py", line 36, in <module>
    import matplotlib.contour as contour
  File "/home/bartosz/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/contour.py", line 21, in <module>
    import matplotlib.font_manager as font_manager
  File "/home/bartosz/.julia/v0.4/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

 [inlined code] from /home/bartosz/.julia/v0.4/PyCall/src/exception.jl:81
 in pyimport at /home/bartosz/.julia/v0.4/PyCall/src/PyCall.jl:392
during initialization of module PyPlot
while loading /home/bartosz/exp.jl, in expression starting on line 4

I tried to do:

  • ENV[“PYTHON”]=""
  • Pkg.build(“PyCall”)

Need help cause I’m kinda new. Any help would be appreciated :slight_smile:


#2

Does your python/matplotlib istallation work (i.e. what the ubuntu package manager installs, not Julia pkgs)? Try running one of the simple examples on matplotlib’s website.


#3

You can try the work-arounds in the libz issue for PyPlot. I also recommend using the binary Julia distributions from the official website rather than the Ubuntu package: Julia v0.4 is no longer supported by the people who matter, and packages like PyPlot have numerous bug fixes not available for v0.4.


#4

https://matplotlib.org/examples/pylab_examples/simple_plot.html I’ve run this example and it works like magic. Julia still doesn’t ;c


#5

Like Ralph_Smith suggested above, please update your julia version to 0.6 or use the latest stable binary and try again please. I just ran your example on a fresh v0.6 install on Ubuntu 16.04 and it worked just fine.