PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

`using PyPlot` fails

Open joshkarges opened this issue 11 years ago • 9 comments
trafficstars

Something in the past few weeks has made PyPlot unusable. I'm on PyCall v0.4.5, PyPlot v1.2.5, and PySide v0.0.2.

in the julia terminal:

julia> using PyPlot
ERROR: PyError (PyImport_ImportModule) 
 in pyerr_check at /Users/joshua/.julia/PyCall/src/exception.jl:58
 in pyimport at /Users/joshua/.julia/PyCall/src/PyCall.jl:85
 in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:259
 in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:447
 in pyimport at /Users/joshua/.julia/PyCall/src/PyCall.jl:105
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:51SYSTEM: show(lasterr) caused an error

in Ijulia:

In[*]: using PyPlot
KERNEL EXCEPTION
access to undefined reference
 in convert at /Users/joshua/.julia/PyCall/src/conversions.jl:82
 in pystring at /Users/joshua/.julia/PyCall/src/PyCall.jl:542
 in show at /Users/joshua/.julia/PyCall/src/exception.jl:35
 in showerror at replutil.jl:66
 in showerror at replutil.jl:74 (repeats 2 times)
 in showerror at replutil.jl:72
 in sprint at io.jl:460
 in pyerr_content at /Users/joshua/.julia/IJulia/src/execute_request.jl:66
           _

_ _ ()_ | A fresh approach to technical computing () | () () | Documentation: http://docs.julialang.org _ _ | | __ _ | Type "help()" to list help topics | | | | | | |/ ` | | | | || | | | (| | | Version 0.3.0-prerelease+2570 (2014-04-09 19:29 UTC) / |_'|||__'| | Commit 4fc2a15 (34 days old master) |__/ | x86_64-apple-darwin13.1.0

joshkarges avatar May 14 '14 18:05 joshkarges

Has something in your Python installation changed, e.g. from a system update?

It sounds like the error is in initializing PyCall, not in PyPlot per se. Try:

using PyCall
pyinitialize()

stevengj avatar May 14 '14 19:05 stevengj

Thank you, we may be getting closer to the root of the problem.

julia> using PyCall

julia> pyinitialize()
ERROR: PyError (PyImport_ImportModule) 
 in pyerr_check at /Users/joshua/.julia/PyCall/src/exception.jl:58
 in pyimport at /Users/joshua/.julia/PyCall/src/PyCall.jl:85
 in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:259
 in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:447
 in pyinitialize at /Users/joshua/.julia/PyCall/src/PyCall.jl:452SYSTEM: show(lasterr) caused an error

joshkarges avatar May 14 '14 19:05 joshkarges

What version of Python do you have? What is your operating system? What does versioninfo(true) report?

Have you tried running Python to see if Python is working?

stevengj avatar May 14 '14 21:05 stevengj

Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:18:52) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin

Operating System: OSX v10.9.2

julia> versioninfo(true)
Julia Version 0.3.0-prerelease+2570
Commit 4fc2a15 (2014-04-09 19:29 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.1.0)
  CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
  WORD_SIZE: 64
  uname: Darwin 13.1.0 Darwin Kernel Version 13.1.0: Wed Apr  2 23:52:02 PDT 2014; root:xnu-2422.92.1~2/RELEASE_X86_64 x86_64 i386
Memory: 16.0 GB (11413.9921875 MB free)
Uptime: 6518.0 sec
Load Avg:  1.44384765625  1.39306640625  1.34423828125
Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz: 
       speed         user         nice          sys         idle          irq
#1  2300 MHz       2571 s          0 s       1698 s      60923 s          0 s
#2  2300 MHz         80 s          0 s         41 s      65069 s          0 s
#3  2300 MHz       1128 s          0 s        503 s      63559 s          0 s
#4  2300 MHz         79 s          0 s         38 s      65074 s          0 s
#5  2300 MHz       1173 s          0 s        494 s      63523 s          0 s
#6  2300 MHz         77 s          0 s         37 s      65076 s          0 s
#7  2300 MHz       1136 s          0 s        505 s      63549 s          0 s
#8  2300 MHz         74 s          0 s         38 s      65078 s          0 s

  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm
Environment:
  GEM_HOME = /Users/joshua/.rvm/gems/ruby-1.9.2-p290
  TERM = xterm-256color
  ARCS_PATH = /Users/joshua/Documents/Data
  MY_RUBY_HOME = /Users/joshua/.rvm/rubies/ruby-1.9.2-p290
  PATH = /Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/joshua/.rvm/gems/ruby-1.9.2-p290/bin:/Users/joshua/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/joshua/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/joshua/cloudlab/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/joshua/.rvm/bin
  WORKSPACE_PATH = /Users/joshua/Documents/Workspaces
  SANDBOX_PATH = /Users/joshua/Documents/GitDepot/cloudlab/src/sandbox/joshua
  HOME = /Users/joshua
  GEM_PATH = /Users/joshua/.rvm/gems/ruby-1.9.2-p290:/Users/joshua/.rvm/gems/ruby-1.9.2-p290@global

Package Directory: /Users/joshua/.julia
11 required packages:
 - ArrayViews                    0.4.4
 - Color                         0.2.9
 - HDF5                          0.2.23
 - HTTPClient                    0.1.4
 - IJulia                        0.1.9
 - ImageView                     0.0.16
 - Images                        0.2.36
 - PyCall                        0.4.5
 - PyPlot                        1.2.5
 - PySide                        0.0.2
 - Winston                       0.11.0
48 additional packages:

python is working.

joshkarges avatar May 14 '14 21:05 joshkarges

Where did you get Python? On my 10.9.2 machine, the Python that comes with the system is 2.7.5.

stevengj avatar May 14 '14 21:05 stevengj

I also have Python 2.7.5.

Python 2.7.5 (default, Sep 12 2013, 21:33:34) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin

When I use that as the default python, then PyCall.pyinitialize() works, but PyPlot still does not.

joshkarges avatar May 14 '14 21:05 joshkarges

If you use the system Python 2.7.5, you should be able to plot in IJulia. Interactive plots won't work in the terminal because MacOS doesn't come with a supported backend for matplotlib. (See the README.)

How did you install Python 2.7.6?

stevengj avatar May 14 '14 23:05 stevengj

You can use Miniconda via the Conda.jl package now. Just do:

ENV["PYTHON"]=""
Pkg.update()
Pkg.build("PyCall")
using PyPlot

and it should install and use matplotlib in the "private" Julia miniconda distribution set up by Conda.

stevengj avatar Sep 24 '15 19:09 stevengj

Note that if you want to use the pyside backend, you will need to do

using Conda
Conda.add("pyside")

stevengj avatar Nov 05 '15 22:11 stevengj