When I use the code normally before compiling it works perfectly but when compiling to .exe with cxfreeze or pyinstaller and running the software freezes
import pyscreenshot as ImageGrab
import threading
def wprint():
print("Wprint")
global tempimg
imagem = ImageGrab.grab()
tempimg = imagem
print("End Wprint")
x = threading.Thread(target=wprint)
x.start()
If we turn on logging, we can see that the module works by spawning a process to run PIL in
When you package your application, it'll try to run the new process against your generated exe as the interpreter (the first argument above), but your script doesn't handle anything from the arguments so it's just started again, which spawn an another process, and this will repeat until your resources are exhausted or until you terminate it.
The pypi home page of the pyscreenshot package mentions that it's mostly obsolete as PIL (pillow) now properly handles what it tried to initially solve, and it appears that it wasn't necessary on your platform. So you can also give pillow's ImageGrab a try directly which should have a normal Python API.