1

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.

Community
  • 1
  • 1
tim_p
  • 31
  • 1
  • 6
  • Do you have to do this on cygwin? I would expect the windows version to work. – simonzack Jan 02 '15 at 14:07
  • Same error in windows cmd: Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Users\BTO-user>python3.2m 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 C:\Users\BTO-user> (I don't know how to paste this nicely) – tim_p Jan 02 '15 at 14:13
  • I mean windows python, `python3.2m` is the cygwin python. Or is it that you have to use cygwin python? – simonzack Jan 02 '15 at 14:31
  • That seems indeed to make a difference. C:\Python33>python.exe Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from PyQt5.QtWidgets import QApplication Traceback (most recent call last): File "", line 1, in ImportError: No module named 'PyQt5.QtWidgets' >> Althought the QtWidgets.dll is in the repository? – tim_p Jan 02 '15 at 15:00
  • cygwin is not a package manager for windows, they are two separate things. You need to install pyqt again on windows. – simonzack Jan 02 '15 at 15:33
  • The initial question is solved but still the thing still refuses working. Do mark this as solved and open an new one? Or? C:\cygwin\bin\TIP\srcpython\fod>C:\Python33\python.exe fod.py test Traceback (most recent call last): File "fod.py", line 14, in from PyQt5.QtWidgets import QApplication ImportError: DLL load failed: The specified module could not be found. I find many related questions on stackoverflow but no solution at this moment. – tim_p Jan 02 '15 at 17:46

1 Answers1

0

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 ]
tim_p
  • 31
  • 1
  • 6