ponty / pyscreenshot

Python screenshot library, replacement for the Pillow ImageGrab module on Linux.
BSD 2-Clause "Simplified" License
502 stars 88 forks source link

pyscreenshot doesn't work on Qpython/Android #56

Closed wavesforthemasses closed 5 years ago

wavesforthemasses commented 5 years ago

Hi, I just installed pyscreenshot on Qpython using Qpypi, but it doesn't work.

Here my code:

from PIL import Image
import pyscreenshot as ImageGrab

im = ImageGrab.grab(bbox=(1,1,2,2))

And here the error:

Traceback (most recent call last): File "/storage/emulated/0/qpython/scripts/pixel.py", line 4, in im = ImageGrab.grab(bbox=(1,1,2,2)) File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/init.py", line 46, in grab return _grab(to_file=False, childprocess=childprocess, backend=backend, bbox=bbox) File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/init.py", line 29, in _grab return run_in_childprocess(_grab_simple, imcodec.codec, to_file, backend, bbox, filename) File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/procutil.py", line 26, in run_in_childprocess queue = Queue() File "/data/user/0/org.qpython.qpy/files/lib/python27.zip/multiprocessing/init.py", line 218, in Queue File "/data/user/0/org.qpython.qpy/files/lib/python27.zip/multiprocessing/queues.py", line 63, in init File "/data/user/0/org.qpython.qpy/files/lib/python27.zip/multiprocessing/synchronize.py", line 147, in init File "/data/user/0/org.qpython.qpy/files/lib/python27.zip/multiprocessing/synchronize.py", line 75, in init OSError: [Errno 38] Function not implemented

Any ideas on why does it happen?

ponty commented 5 years ago

Android is not supported in pyscreenshot.

I could not install Qpython+Pillow. I tried it on my phone and on various x86 Android virtual machines.

The log shows that multiprocessing is not working. It's a Qpython problem.

You can try without multiprocessing:

im = ImageGrab.grab(bbox=(1,1,2,2), childprocess=False)
wavesforthemasses commented 5 years ago

Your suggestion made that warning disappear but now it claims that I've no backend. But isn't PIL my backend actually? Sorry I'm not developing in python usually :)

/data/user/0/org.qpython.qpy/files/bin/qpython-android5.sh "/storage/emulated/0/qpython/scripts/pixel.py" && exit qpython/scripts/pixel.py" && exit < Traceback (most recent call last): File "/storage/emulated/0/qpython/scripts/pixel.py", line 9, in im = ImageGrab.grab(bbox=(1,1,2,2), childprocess=False) File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/init.py", line 46, in grab return _grab(to_file=False, childprocess=childprocess, backend=backend, bbox=bbox) File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/init.py", line 31, in _grab return _grab_simple(to_file, backend, bbox, filename) File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/init.py", line 18, in _grab_simple backend_obj = loader.selected() File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/loader.py", line 76, in selected self.raise_exc() File "/data/user/0/org.qpython.qpy/files/lib/python2.7/site-packages/pyscreenshot/loader.py", line 84, in raise_exc raise FailedBackendError(message) pyscreenshot.loader.FailedBackendError: Install at least one backend! 1|cedric:/ $

P.S. this is not a question of life or death, if you are busy don't worry. I just wanted to improve an automation adding the ability to take decisions based on pixel colors. I can do it with other tools, but it's super slow..so I was trying to use python. But generally speaking my code already does what I need, even without this extra feature :) so don't waste your time on it unless it's something interesting.

ponty commented 5 years ago

Please check the README. PIL backend works on Windows only. pyscreenshot is just a wrapper for existing backends and Android backend is not implemented.