I found a resolution. Updating Ipython to 3.0.0. The way you initialize 
your ipython qtconsole with the "--pylab=qt" tag allows pyqtgraph to fully 
integrate with ILeo.

Awesome. This also fixes the bug from the bug report, which I will update.

On Saturday, March 14, 2015 at 12:32:12 PM UTC-4, john lunzer wrote:
>
> I think I've made some progress on this. I posted a bug report ( 
> https://github.com/leo-editor/leo-editor/issues/155 ) that I believe is 
> related but I don't know how to fix either one.
>
> My discovery came from doing some experiments with a stand alone ipython 
> qt console. I believe these issues are coming from using the Qt API v1 
> versus the v2 ( think it should always be using v2). 
>
> If you: 
> import PyQt4
>
> %gui qt
>
> import PyQt4
>
> ---------------------------------------------------------------------------
> ImportError                               Traceback (most recent call last)
> <ipython-input-3-0c3b8c686717> in <module>()
> ----> 1 import PyQt4
>
> C:\Anaconda\lib\site-packages\IPython\external\qt_loaders.pyc in 
> load_module(self, fullname)
>      45     Importing %s disabled by IPython, which has
>      46     already imported an Incompatible QT Binding: %s
> ---> 47     """ % (fullname, loaded_api()))
>      48 
>      49 ID = ImportDenier()
>
> ImportError: 
>     Importing PyQt4 disabled by IPython, which has
>     already imported an Incompatible QT Binding: pyqtv1
>
>
> The second import will fail.
>
> I found a lead on, 
> http://cyrille.rossant.net/making-pyqt4-pyside-and-ipython-work-together/ 
> which 
> contains the following code snippit:
>
> import sip
> try:
>     sip.setapi('QDate', 2)
>     sip.setapi('QDateTime', 2)
>     sip.setapi('QString', 2)
>     sip.setapi('QtextStream', 2)
>     sip.setapi('Qtime', 2)
>     sip.setapi('QUrl', 2)
>     sip.setapi('QVariant', 2)
> except ValueError, e:
>     raise RuntimeError('Could not set API version (%s): did you import 
> PyQt4 directly?' % e)
>
> Now if in the stand alone if I run: 
>
> import PyQt4
>
> import sip
> try:
>     sip.setapi('QDate', 2)
>     sip.setapi('QDateTime', 2)
>     sip.setapi('QString', 2)
>     sip.setapi('QtextStream', 2)
>     sip.setapi('Qtime', 2)
>     sip.setapi('QUrl', 2)
>     sip.setapi('QVariant', 2)
> except ValueError, e:
>     raise RuntimeError('Could not set API version (%s): did you import 
> PyQt4 directly?' % e)
>
> %gui qt
>
> import PyQt4
>
> Both imports succeed.
>
> Two things, I wouldn't know where to add Cyrille's code snippet and I'm 
> also not sure what the "%gui qt" magic is doing programmatically. I will 
> also add this finding to the bug report.
>
> If anyone has any thoughts on making sure the v2 API is loaded please let 
> me know.
>
>
> On Friday, March 13, 2015 at 12:40:03 PM UTC-4, john lunzer wrote:
>>
>> I make heavy use of a library called PyQtGraph. I am trying to:
>>
>> import pyqtgraph as pg
>>
>> But in the Leo IPython qtconsole I am getting:
>>
>> import pyqtgraph as pg
>>
>>
>> ---------------------------------------------------------------------------
>> Exception                                 Traceback (most recent call 
>> last)
>> <ipython-input-1-e5a51b506085> in <module>()
>> ----> 1 import pyqtgraph as pg
>>
>>
>> C:\Anaconda\lib\site-packages\pyqtgraph\__init__.py in <module>()
>>      11 ## 'Qt' is a local module; it is intended mainly to cover up the 
>> differences
>>      12 ## between PyQt4 and PySide.
>> ---> 13 from .Qt import QtGui
>>      14 
>>      15 ## not really safe--If we accidentally create another 
>> QApplication, the process hangs (and it is very difficult to trace the 
>> cause)
>>
>>
>> C:\Anaconda\lib\site-packages\pyqtgraph\Qt.py in <module>()
>>      30             USE_PYSIDE = True
>>      31         except ImportError:
>> ---> 32             raise Exception("PyQtGraph requires either PyQt4 or 
>> PySide; neither package could be imported.")
>>      33 
>>      34 if USE_PYSIDE:
>>
>>
>> Exception: PyQtGraph requires either PyQt4 or PySide; neither package 
>> could be imported.
>>
>> I have also cross posted to the pyqtgraph developer's google group.
>>
>> I found that if I attempt the same import in a standalone IPython 
>> QtConsole window using the "--gui=qt" tag I get the same error, so I'm 
>> wondering if Leo uses the same tag. And possibly how we can get around it.
>>
>> I'm very excited by what Leo has to offer, specifically using clones.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to