BlackBox
BlackBox

Reputation: 643

Taking screenshot in Python not working anymore on macOS since Catalina

I used prior to Catalina the library pyscreenshot to make programmatically screenshots in Python.

I do not know if the OS update broke something, but since, when I do screenshots from code,

e.g.

# bbox declared in context
import pyscreenshot as ImageGrab
if os.name == 'nt':
    # Windows
    im = ImageGrab.grab(bbox=bbox)
else:
    # macOS (I don't worry about Linux)
    im = ImageGrab.grab(bbox=bbox, backend='mac_quartz', childprocess=False)

# ...
im.save(filename)

I get a screenshot of the clean desktop instead of the apps shown on screen.

I also tried (uglier but better a thing that works than nothing)

os.system("screencapture %s" % filename)

but the same thing happens.

Is there a way to fix this situation?

Upvotes: 3

Views: 1150

Answers (1)

bobthemac
bobthemac

Reputation: 1172

You need to go to System Preferences > Security & Privacy and allow your terminal under the screen recording option it should then allow you to take screenshots.

See Github Issue

Upvotes: 2

Related Questions