Reputation: 25
This has been troubling me for the past hour. My python script won't run; however, if I select 'check module', input the code, and run the same thing it works. It's a very simple script:
import pyscreenshot as getImage
im = getImage.grab(bbox=(1300,800,1500,850))
im.save("screen.png")
Upvotes: 1
Views: 1243
Reputation: 26037
You need to set childprocess=False
as IDLE has problems with multiprocessing. IDLE runs user code in a separate process so with pyscreenshot IDLE hangs and seems like the module won't work. You may go through this to know more.
An option is to turn off multiprocessing by setting childprocess=False
.
Try:
import pyscreenshot as getImage
im = getImage.grab(bbox=(1300,800,1500,850), childprocess=False)
im.save("screen.png")
Upvotes: 0
Reputation: 11603
Try running through terminal and it will work.
Although I do not know why this happens exactly (probably ask those who maintain it) I can tell you it is because of some terminal dependant function that is created while running.
The IDLE is not actually a terminal so it cannot run exactly like a terminal (although it outputs the same content, it is not a terminal). For example running os.get_terminal_size()
under the IDLE will not work yet the terminal will. There are also some functions in PIL that perform in the same way.
Anyway this post shows a pretty similar code and it is mentioned it doesn't work under the IDLE.
Upvotes: 1