Search code examples
pythonscreenshotpyinstaller

Pyscreenshot doesn't work with PyQt5(Pyinstaller)


When I am running my app from IDE, it works great, but if I run app built with PyInstaller, pyscreenshot.grab works like MainWindow.show(). I tried 3 different backends(PyQt5; PIL; default) and none of them work. If you dont understood me, you can watch video

If I close window, an error appears:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "threading.py", line 926, in _bootstrap_inner
  File "threading.py", line 870, in run
  File "main1.py", line 96, in main
  File "lib\site-packages\pyscreenshot\__init__.py", line 31, in grab
  File "lib\site-packages\pyscreenshot\loader.py", line 145, in backend_grab
  File "lib\site-packages\pyscreenshot\loader.py", line 136, in force
  File "lib\site-packages\pyscreenshot\childproc.py", line 39, in childprocess_grab
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\pyscreenshotmrgm1pkk\\screenshot.png'

P.S. I am using dev version of PyInstaller, because I need TensorFlow support


Solution

  • Using PIL.ImageGrab.grab() instead of ps.grab() fixed problem