PyPlot do not work on julia 0.6

PyPlot used to work with previous RC versions. It errors with the release version. I tried deleting all files in ~/.julia/lib and ~/.julia/v0.6 and do a fresh start, just installing PyPlot and set ENV["PYTHON"]="". However, the same error still occurs. Does anyone have the same issue?

  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0 (2017-06-19 13:05 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> using PyPlot
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
/home/lizz/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py:1405: 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.

  warnings.warn(_use_error_msg)
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
WARNING: No working GUI backend found for matplotlib
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
ERROR: InitError: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)) <type 'exceptions.ImportError'>
ImportError('numpy.core.multiarray failed to import',)
  File "/home/lizz/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/home/lizz/.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/lizz/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/contour.py", line 15, in <module>
    import matplotlib._cntr as _cntr

Stacktrace:
 [1] pyerr_check at /home/lizz/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
 [2] pyerr_check at /home/lizz/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
 [3] macro expansion at /home/lizz/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
 [4] pyimport(::String) at /home/lizz/.julia/v0.6/PyCall/src/PyCall.jl:394
 [5] __init__() at /home/lizz/.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_search_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:236
 [9] _require(::Symbol) at ./loading.jl:434
 [10] require(::Symbol) at ./loading.jl:398
during initialization of module PyPlot

Sounds like you have conflicting numpy versions on your system and Python is getting confused about which one to load. Things to try:

  • Check you environment variables, to make sure you have nothing like PYTHONPATH defined that would confuse Python (since you are using the Conda python, you don’t want it to get confused with some other python installed on your system).

  • Since you are on Linux, try using the system Python instead of Conda. Do ENV["PYTHON"]="python"; Pkg.build("PyCall") and use your system’s packaging tools to install Matplotlib if it is not installed already.

1 Like

Thanks a lot! This line of code works!