Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPlot not initializing; pltm not defined #108

Closed
ghost opened this issue Dec 11, 2014 · 18 comments
Closed

PyPlot not initializing; pltm not defined #108

ghost opened this issue Dec 11, 2014 · 18 comments

Comments

@ghost
Copy link

ghost commented Dec 11, 2014

Typing

Pkg.add("PyPlot")
using PyPlot

from julia 0.3.3 results in:
[[
Warning: error initializing module PyPlot:
PyCall.PyError(msg=":PyImport_ImportModule", T=PyCall.PyObject(o=0x0000000043382540), val=PyCall.PyObject(o=0x000000003f48dab8), traceback=PyCall.PyObject(o=0x000000003e91bef0))
]](delimiters [[ ]] added)

When trying to run

@pyimport matplotlib.pyplot as plt

The result is:
[[
ERROR: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('cannot import name scimath',)
File "/usr/lib64/python2.7/site-packages/matplotlib/init.py", line 179, in
from matplotlib.cbook import is_string_like
File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 32, in
import numpy as np
File "/usr/lib64/python2.7/site-packages/numpy/init.py", line 170, in
from . import add_newdocs
File "/usr/lib64/python2.7/site-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/lib64/python2.7/site-packages/numpy/lib/init.py", line 17, in
from . import scimath as emath

in pyerr_check at /home/jdgallag/.julia/v0.3/PyCall/src/exception.jl:58
in pyimport at /home/jdgallag/.julia/v0.3/PyCall/src/PyCall.jl:91
]]

What can be done?

@stevengj
Copy link
Member

Are you using Canopy/EPD Python? Canopy isn't supported (JuliaPy/PyCall.jl#42), and I would recommend Anaconda if that is the case.

@ghost
Copy link
Author

ghost commented Dec 11, 2014

No, I am using the Python 2.7.8 that comes with OpenSUSE. I installed python and matplotlib through zypper install.

Is anaconda required for this package?

@stevengj
Copy link
Member

No, Anaconda is not required. Does Pkg.test("PyCall") work?

@ghost
Copy link
Author

ghost commented Dec 12, 2014

No it does not.

Here is the output
[[
julia> Pkg.test("PyCall")
INFO: Testing PyCall
ERROR: test failed: (obuf[:seek])(-2,1) == position(buf) == 3
in error at error.jl:21
in default_handler at test.jl:19
in do_test at test.jl:39
in anonymous at no file:114
in include at ./boot.jl:245
in include_from_node1 at loading.jl:128
in process_options at ./client.jl:285
in _start at ./client.jl:354
in _start_3B_1732 at /home/jdgallag/Software/julia0.3/julia-b24213b893/bin/../lib/julia/sys.so
while loading /home/jdgallag/.julia/v0.3/PyCall/test/runtests.jl, in expression starting on line 107

===============================[ ERROR: PyCall ]================================

failed process: Process(/home/jdgallag/Software/julia0.3/julia-b24213b893/bin/julia /home/jdgallag/.julia/v0.3/PyCall/test/runtests.jl, ProcessExited(1)) [1]

INFO: No packages to install, update or remove
ERROR: PyCall had test errors
in error at error.jl:21
in test at pkg/entry.jl:718
in anonymous at pkg/dir.jl:28
in cd at ./file.jl:20
in cd at pkg/dir.jl:28
in test at pkg.jl:67
]]

@ghost
Copy link
Author

ghost commented Dec 12, 2014

I am actually suspicious that the culprit might be the precompiled binary julia distribution I am using. I compiled v0.4 from git, and the tests are passing. Is there anyway I can obtain v0.3 from git? Or if v0.4 is stable enough do you recommend? I saw there are some issues with cairo on v0.4, but if everything else is better there, maybe I should just use 0.4..?

@ghost
Copy link
Author

ghost commented Dec 12, 2014

Confirmed, it is an issue with the precompiled julia binary. Built julie v0.3.4-pre from git, and everything works great.

@ghost ghost closed this as completed Dec 12, 2014
@stevengj
Copy link
Member

Great! Still wish I knew precisely what the problem with their julia binary was...

@ghost
Copy link
Author

ghost commented Dec 12, 2014

How could I investigate that? I could do some digging, but I don't
know very much about python...

On Fri, Dec 12, 2014 at 9:38 AM, Steven G. Johnson
[email protected] wrote:

Great! Still wish I knew precisely what the problem with their julia
binary was...


Reply to this email directly or view it on GitHub.

@stevengj
Copy link
Member

Maybe put some print statements around the PyCall test that fails, to get more info?

stevengj added a commit to JuliaPy/PyCall.jl that referenced this issue Dec 17, 2014
@stevengj
Copy link
Member

I think the PyCall test failure was spurious, and should be fixed in the latest PyCall version; can you try again after a Pkg.update()?

@lkuper
Copy link

lkuper commented Mar 26, 2015

FWIW, I'm having a very similar issue with Julia 0.3.7 and PyPlot 1.5.1:

lkuper@lkuper-u1404:~$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.7 (2015-03-23 21:36 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
|__/                   |  x86_64-linux-gnu

julia> Pkg.add("PyPlot")
INFO: Initializing package repository /home/lkuper/.julia/v0.3
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
INFO: Cloning cache of Color from git://github.com/JuliaLang/Color.jl.git
INFO: Cloning cache of Compat from git://github.com/JuliaLang/Compat.jl.git
INFO: Cloning cache of Dates from git://github.com/quinnj/Dates.jl.git
INFO: Cloning cache of FixedPointNumbers from git://github.com/JeffBezanson/FixedPointNumbers.jl.git
INFO: Cloning cache of Graphics from git://github.com/JuliaLang/Graphics.jl.git
INFO: Cloning cache of LaTeXStrings from git://github.com/stevengj/LaTeXStrings.jl.git
INFO: Cloning cache of PyCall from git://github.com/stevengj/PyCall.jl.git
INFO: Cloning cache of PyPlot from git://github.com/stevengj/PyPlot.jl.git
INFO: Installing Color v0.4.2
INFO: Installing Compat v0.3.6
INFO: Installing Dates v0.3.2
INFO: Installing FixedPointNumbers v0.0.6
INFO: Installing Graphics v0.1.0
INFO: Installing LaTeXStrings v0.1.2
INFO: Installing PyCall v0.7.4
INFO: Installing PyPlot v1.5.1
INFO: Package database updated

julia> using PyPlot
Warning: error initializing module PyPlot:
PyCall.PyError(msg=":PyImport_ImportModule", T=PyCall.PyObject(o=0x00000000ed2e41e0), val=PyCall.PyObject(o=0x00000000eca36200), traceback=PyCall.PyObject(o=0x0000000000000000))

I have Python 2.7.6, if that's relevant.

@stevengj
Copy link
Member

@lkuper, not all errors in initializing matplotlib have the same origin, unfortunately. If we figure out a specific reason for yours it is likely to be a separate issue. That takes some digging to find out specifically what module import is failing, I'm afraid.

For example, if you are using Ubuntu, I had a report recently that the Ubuntu Matplotlib is set up to support the GTK3 backend by default, but PyCall has not implemented the GTK3 event loops yet so it can't initialize properly for interactive use. You can try using PyCall; pygui(:qt); using PyPlot to force it to use the Qt backend.

@lkuper
Copy link

lkuper commented Apr 1, 2015

@stevengj, I see, thanks. Yes, this issue was on Ubuntu.

FWIW, though, using PyCall; pygui(:qt); using PyPlot produces the same error:

julia> using PyCall; pygui(:qt); using PyPlot
Warning: error initializing module PyPlot:
PyCall.PyError(msg=":PyImport_ImportModule", T=PyCall.PyObject(o=0x000000005b7e81e0), val=PyCall.PyObject(o=0x000000005afb37e8), traceback=PyCall.PyObject(o=0x0000000000000000))

@vote539
Copy link

vote539 commented Apr 7, 2015

Confirming this issue in the Ubuntu release of Julia, which I just installed yesterday on Ubuntu 14.04 according to the instructions on this page. Rather than building from source I am experimenting with Gadfly for my plotting needs, which so far seems to be working, although I miss a lot of the features of PyPlot.

@stevengj
Copy link
Member

stevengj commented Apr 7, 2015

I think it should be straightforward to add gtk3 support to PyCall; I just don't have access to an Ubuntu machine at the moment.

@iagobaapellaniz
Copy link

I use Julia on a Mac OS X, and I get the same error:

Warning: error initializing module PyPlot:
PyCall.PyError(msg=":PyImport_ImportModule", 
T=PyCall.PyObject(o=0x000000000b236e58), 
val=PyCall.PyObject(o=0x000000000b6743c8), 
traceback=PyCall.PyObject(o=0x0000000000000000))

I've installed PyPlot with no problem, Pkg.test("PyCall") passed.

@stevengj
Copy link
Member

@Iagoba, what happens if you import matplotlib in Python?

@iagobaapellaniz
Copy link

@stevengj It works also just fine with one of the versions of python. More concretely the 3.4. I have also installed the 2.7 but no matplotlib for this.

$ python3.4 -c 'import matplotlib; print(matplotlib.__version__, matplotlib.__file__)'
1.4.3 /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/__init__.py

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants