Pyscreenshot不能与PyQt5(Pyinstaller)一起使用。

问题描述 投票:0回答:1

当我从IDE运行我的应用程序时,它工作得很好,但如果我运行用PyInstaller构建的应用程序。pyscreenshot.grab 运作方式 MainWindow.show(). 我尝试了3个不同的后端(PyQt5; PIL; 默认),但它们都不工作。如果你不明白我的意思,你可以看一看 视频

如果我关闭窗口,会出现一个错误。

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. 我正在使用PyInstaller的开发版,因为我需要TensorFlow支持。

python screenshot pyinstaller
1个回答
0
投票

使用 PIL.ImageGrab.grab() 而不是 ps.grab() 解决了问题

© www.soinside.com 2019 - 2024. All rights reserved.