Opened 12 years ago

Closed 12 years ago

#31466 closed defect (invalid)

py27-matplotlib say py27-pyqt4 not installed when using qt-backend

Reported by: bussonniermatthias@… Owned by: skymoo (Adam Mercer)
Priority: Normal Milestone:
Component: ports Version:
Keywords: pyqt, matplotlib Cc:
Port: py27-matplotlib

Description

When trying to use matplotlib 27 with qt back end through the following example: http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_qt.html

matplotlib complain that pyqt is not installed

Traceback (most recent call last):
  File "embedding_in_qt.txt", line 15, in <module>
    from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_qtagg.py", line 12, in <module>
    from backend_qt import qt, FigureManagerQT, FigureCanvasQT,\
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_qt.py", line 21, in <module>
    raise ImportError("Qt backend requires pyqt to be installed.")
ImportError: Qt backend requires pyqt to be installed.

still i'm (almost) sure matplotlib ans pyqt4 are correcty installed (+qt4 variants)

py27-matplotlib @1.0.1_5+qt4 (active)
py27-pyqt4 @4.8.4_0 (active)

looking at the rainsing error file we get:

try:¬
    import qt¬
except ImportError:¬
    raise ImportError("Qt backend requires pyqt to be installed.")

replacing by something like: import PyQt4.Qt as qt does allow the file to load correctly,but error are thrown later when trying to instanciate object.

Change History (10)

comment:1 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Milestone: MacPorts 2.0.4
Owner: changed from macports-tickets@… to ram@…

comment:2 Changed 12 years ago by skymoo (Adam Mercer)

Version: 2.0.3

Which platform?

comment:3 Changed 12 years ago by bussonniermatthias@…

Ouh, sorry, right. Mac OS X 10.6.7, on a mid 2011, macbookpro 6.2 (mid 2010) MacPorts 2.0.3

comment:4 Changed 12 years ago by skymoo (Adam Mercer)

Trying to reproduce the problem here, what version of Xcode are you using? Also any reason why you haven't updated to 10.6.8?

comment:5 Changed 12 years ago by bussonniermatthias@…

not mid 2011, mid 2010, i miss-copied and past... a little too early in the morning here.. xCode 3.2.6. And I didn't upgrade because i have a really slow internet connection for now, software update cant even "find new software" for example today "network issues" even if the rest of internet is working. I'm also using my personal laptop work too. So I prefere upgrading when I'll be sure to have time to fix things if they are broken by an update.

comment:6 Changed 12 years ago by skymoo (Adam Mercer)

The qt4 variant seems to work fine for me:

$ port installed py27-matplotlib
The following ports are currently installed:
  py27-matplotlib @1.0.1_5+qt4 (active)
$ python
Python 2.7.2 (default, Aug 22 2011, 13:53:27) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.use("Qt4Agg")
>>> import pylab
>>> pylab.plot([1,2,3,4])
[<matplotlib.lines.Line2D object at 0x1099bcb50>]
>>> pylab.show()

At which point the appropriate plot is displayed. Can you attach an example program that's failing?

comment:7 Changed 12 years ago by bussonniermatthias@…

Your code work ok. this one doesn't:

>>> import matplotlib  #optionnal, but to be sure
>>> matplotlib.use("Qt4Agg") #optionnal, but to be sure
>>> from PyQt4.Qt import *
>>> from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_qtagg.py", line 12, in <module>
    from backend_qt import qt, FigureManagerQT, FigureCanvasQT,\
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_qt.py", line 21, in <module>
    raise ImportError("Qt backend requires pyqt to be installed.")
ImportError: Qt backend requires pyqt to be installed.

some matplotlib example (first post link) also failed, but, this might be an error in the example.

import sys, os, random
from qt import *  # <---- doesn't import

from numpy import arange, sin, pi
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas

comment:8 Changed 12 years ago by skymoo (Adam Mercer)

Ahh, I see whats going on. The qt4 variant provides the qt4 and qt4agg backends, you're trying to use qt which is the backend based on QT3, hence it's not found.

comment:9 Changed 12 years ago by bussonniermatthias@…

Oh I see ... sorry then I didn't new 'qt' was implying qt3.

So maybe the message must be more explit like "this Qt backend requires pyqt3 to be installed." but his is more a matplotlib upstream issues i think. And maybe Matplotlib example should be updated to also make use of Qt4 .

Thank you.

comment:10 in reply to:  9 Changed 12 years ago by skymoo (Adam Mercer)

Resolution: invalid
Status: newclosed

Replying to bussonniermatthias@…:

So maybe the message must be more explit like "this Qt backend requires pyqt3 to be installed." but his is more a matplotlib upstream issues i think. And maybe Matplotlib example should be updated to also make use of Qt4 .

The QT3 python bindings are called pyqt, so it's reporting that the appropriate module is missing.

Note: See TracTickets for help on using tickets.