Search code examples
pythoncygwinqt5pyqt5

Import QApplication fails without error (python3)


I'm trying to implementate a solution provided at Take a screenshot via a python script. [Linux] in a python script:

from PyQt5.QtWidgets import QApplication
app = QApplication([])
screen = app.primaryScreen()
screenshot = screen.grabWindow(QApplication.desktop().winId())
screenshot.save('/tmp/screenshot.png')

When running this code python just stops working without spawning an error.

BTO-user@BTO /srcpython/fod
Python 3.2.5 (default, Jul 28 2014, 01:44:48)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtWidgets import QApplication

BTO-user@BTO /srcpython/fod

The module PyQt5 is installed, but these are .dll files. Normally when I install a module there should be source files. These dll files should be a binding to Qt5 and I installed this via the cygwin dev installer. Probably something is incorrect with 1 of these 2 installations, but I tried already many re-installs. It bugs me there is not a single error report.


Solution

  • The suggestion from @simonzack lead to the solution. I ran the command in the cygwin environment, but after it ran in the normal windows environment it gave more descriptive (more or less) errors.

    [The error about the DLL load failed: The specified module could not be found is solved by a combination of actions:

    • be sure to take the last possible version http://sourceforge.net/projects/pyqt/files/PyQt5/
    • add to the environmentvariable path the repository of the PyQt5 installation of the windowsversion of pythong and the repository of the Qt5 installation in windows ]