Forums

Unable to take screenshots using a Python 3 script

I've been looking for different ways to take screenshots of my desktop using a Python 3 script to no avail. I've tried installing pyscreenshot but had no success with it, there's always this error - OS Error: cannot identify image file '/tmp/pyscreenshot_imagemagick_tkh67ll1.png' I'm also unable to install Scrot or Gnome on Ubuntu as sudo is unavailable here.

Any information would be greatly appreciated!

Screenshots are unlikely to work on PythonAnywhere -- it's a server-based, text-only environment so there's no graphical screen to capture. What do you need the screenshots for? Perhaps there's an alternative way to achieve the effect you want.

I'm taking screenshots of text and then using tesseract OCR to perform searches on the extracted text.

Where is the text coming from?

From local Images stored on my Desktop and some PDF files too.

For the images -- can't you just feed them into tesseract directly? PDFs you can convert into images using the pdfimages command.