2

I had EPD installed and am giving Canopy (Windows 7 64-bit, Academic license) a go. When I first started Canopy, nothing happened (no GUI, no error message) and I realized this is because I had QT_API set to pyqt. Changing qt_api to pyside allows me to start Canopy. After doing this I have checked that pyqt is installed through the Canopy package manager. However Canopy refuses to start with QT_API set to pyqt. How can I fix this? I have a big project with everything in pyqt, so I want to use it.

Tim Rae
  • 3,167
  • 2
  • 28
  • 35

1 Answers1

1

Since Canopy GUI application runs in a different process than Canopy User Python, they can use different GUI backends.

At present, the Canopy GUI application is Pyside-only, because of PyQt's GPL license. I think, therefore, that Canopy GUI should be ignoring QT_API (or internally forcing it), so that you could set it however you want for your application. However from your report this does not seem to be the case.

As a workaround, the first thing that I would try would be to begin your main module (before any backend-dependent imports) by setting os.environ['QT_API'] = 'pyqt'.

Jonathan March
  • 5,800
  • 2
  • 14
  • 16
  • 1
    I just re-installed Canopy on a new PC, and am having trouble with the Canopy iPython console. I have a class that inherits from `PyQt4.QtCore.QObject`, but when I try to import it I get an import error, presumably because Canopy tries to automatically import pylab with pyside: `ImportError: Importing PyQt4 disabled by IPython, which has already imported an Incompatible QT Binding: pyside` – Tim Rae Apr 14 '15 at 07:50
  • 1
    By the way, it's kind of astounding that the originally reported bug still exists almost 2 years after I reported it... Canopy 1.5.2.2785 doesn't start at all (i.e. fails silently) with QT_API environment variable set to 'pyqt' – Tim Rae Apr 14 '15 at 07:52
  • 1
    Fixed in Canopy 1.6.1 Re fix, see http://docs.enthought.com/canopy/configure/release-notes.html#fixed-unable-to-use-gui-backends-other-than-pyside-3821, re updating, see https://support.enthought.com/hc/en-us/articles/204469570-Canopy-shows-no-updates-available-reinstalling-from-the-website – Jonathan March Nov 29 '15 at 19:10
  • 1
    I'm having terrific problems just trying to make a simply pop-up window with PyQt4, asking for a folder name. I keep getting the error: **ImportError: Importing PyQt4 disabled by IPython, which has already imported an Incompatible QT Binding: pyside** when I perform a from **PyQt4 import QtGui** I have Canopy 1.6.2. so I don't think this bug has been fixed as Was suggested in the previous comment? – thescoop Apr 09 '16 at 22:18
  • Does it help to disable PyLab mode in the Canopy preferences dialog ("Python" tab)? – Jonathan March Apr 10 '16 at 23:49
  • I disabled PyLab in Canopy and now I don't get the error... but still don't get anything to pop up when executing this simple hello world code. https://www.tutorialspoint.com/pyqt/pyqt_hello_world.htm – James Paul Mason Jan 30 '17 at 18:16
  • @JamesPMason what operating system? Did you check to see whether the window was actually created, but was hidden beneath the main window instead of on top of it? – Jonathan March Jan 30 '17 at 20:33
  • Mac. I did check that. I re-enabled PyLab but realized that the tutorial was using PyQt whereas Canopy uses PySide (I hadn't realized those were two separate wrappers for Qt). I've since gotten a step farther. Now the problem is: RuntimeError: A QApplication instance already exists. That's strange because it's a fresh instance of Canopy with no previous executed code. – James Paul Mason Jan 31 '17 at 00:23
  • Our of curiosity, why did you re-enable PyLab? It takes a bit more work but you can write your PySide app to run with or without PyLab. See ["Getting PySide Hello App to run under Canopy"](http://stackoverflow.com/a/27538200/1988991) – Jonathan March Jan 31 '17 at 12:51