Problem with "using PyPlot"

378 views
Skip to first unread message

Ilya Orson

unread,
Nov 23, 2015, 8:17:35 AM11/23/15
to julia-users
Hello everyone!

I am having some trouble with PyPlot, can somebody help me?

I have Anaconda's Python 2.7 installed and normally Julia recognized it while using PyPlot and PyCall but it suddenly failed today while importing PyPlot:

ERROR: InitError: Failed to pyimport("matplotlib"): PyPlot will not work until you have a functioning matplotlib module.

For automated Matplotlib installation, try configuring PyCall to use the Conda Python distribution within Julia.  Relaunch Julia and run:
      ENV["PYTHON"]=""
      Pkg.build("PyCall")
      using PyPlot

pyimport exception was: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so: undefined symbol: zgelsd_',)
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/matplotlib/cbook.py", line 32, in <module>
    import numpy as np
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/lib/__init__.py", line 18, in <module>
    from .polynomial import *
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 20, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 51, in <module>
    from .linalg import *
  File "/home/ilya/anaconda2/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 29, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg

 in __init__ at /home/ilya/.julia/v0.4/PyPlot/src/PyPlot.jl:229
 in _require_from_serialized at loading.jl:84
 in _require_from_serialized at ./loading.jl:109
 in require at ./loading.jl:219
during initialization of module PyPlot

So I tried to reinstall julia and set ENV["PYTHON"] = "" before adding PyCall to force the usage of Conda.jl ,
then I added PyPlot and everything seemed fine until then, but when I use import PyPlot I get the following error:

ERROR: InitError: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('cannot import name scimath',)
  File "/home/ilya/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
  File "/home/ilya/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/cbook.py", line 32, in <module>
    import numpy as np
  File "/home/ilya/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/home/ilya/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/ilya/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 17, in <module>
    from . import scimath as emath

 [inlined code] from /home/ilya/.julia/v0.4/PyCall/src/exception.jl:81
 in pyimport at /home/ilya/.julia/v0.4/PyCall/src/PyCall.jl:302
 in __init__ at /home/ilya/.julia/v0.4/PyPlot/src/PyPlot.jl:227
 in _require_from_serialized at loading.jl:84
 in _require_from_serialized at ./loading.jl:109
 in require at ./loading.jl:219
during initialization of module PyPlot

I get the same error if I try to use the development branch of PyCall instead:
Pkg.checkout("PyCall")
ENV
["PYTHON"] = ""

Pkg.build("PyCall")


And I get the same error when I try to use Anaconda as before by setting ENV["PYTHON"] = "python" and building PyCall again. (with both versions of PyCall)

The problem always appears when I try using PyPlot.

I don't know if this helps but if I try to continue and plot something I get the following:

ERROR: ArgumentError: haskey of NULL PyObject
 in haskey at /home/ilya/.julia/v0.4/PyCall/src/PyCall.jl:260
 in plot at /home/ilya/.julia/v0.4/PyPlot/src/PyPlot.jl:457

Any help would be highly apreciated!

Thanks,
Ilya

Steven G. Johnson

unread,
Nov 23, 2015, 9:32:39 AM11/23/15
to julia-users
Are you on Ubuntu and using the Julia binary there?  If so, it looks like you are running into


(see the discussion at the very end) due to a conflict between the openblas in Ubuntu and the openblas that numpy wants to link to.  See the issue for workarounds.

Ilya Orson

unread,
Nov 24, 2015, 1:12:51 PM11/24/15
to julia-users
I am on Ubuntu 14.04 and using the Julia PPA. 

The problem discussed in the issue is the same  I have indeed. 

A solution that worked for me was to uninstall anaconda and install everything from the pip-python manager and then set Julia ENV["PYTHON"]to detect that python path.

Thanks!
Reply all
Reply to author
Forward
0 new messages