ponty / pyscreenshot

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

Replaced hardcoded "python" excutable name with sys.executable #8

Closed PamelaM closed 11 years ago

PamelaM commented 11 years ago

pyscreenshot wasn't working if pyscreenshot wasn't installed in the environment currently associated with the "python" command.

In my case, I was using it in my "python2.6" environment without using venv's.

By using sys.exectuable instead of hardcoding 'python', the EasyProcess calls will use the same python executable as the caller.

Here's the traceback I was getting:

img = disp.waitgrab() \Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.6/site-packages/pyvirtualdisplay/smartdisplay.py", line 68, in waitgrab img = self.grab(autocrop=autocrop) File "/Library/Python/2.6/site-packages/pyvirtualdisplay/smartdisplay.py", line 40, in grab img = pyscreenshot.grab(childprocess=1, backend=self.pyscreenshot_backend) File "/Library/Python/2.6/site-packages/pyscreenshot/init.py", line 36, in grab "import pyscreenshot; pyscreenshot.grab_to_file(%s)" % params, File "/Library/Python/2.6/site-packages/easyprocess/init.py", line 183, in check raise EasyProcessError(self, 'check error, return code is not zero!') easyprocess.EasyProcessError: check error, return code is not zero! <EasyProcess cmd_param=['python', '-c', "import pyscreenshot; pyscreenshot.grab_to_file('/var/folders/H4/H4JS2F+iHyudZ-nYRNIiMk+++TI/-Tmp-/pyscreenshot_childprocess_OX4byu.png',childprocess=False)"] alias={alias} cmd=['python', '-c', "import pyscreenshot; pyscreenshot.grab_to_file('/var/folders/H4/H4JS2F+iHyudZ-nYRNIiMk+++TI/-Tmp-/pyscreenshot_childprocess_OX4byu.png',childprocess=False)"] ({scmd}) oserror=None returncode=1 stdout="" stderr="Traceback (most recent call last): File "", line 1, in ImportError: No module named pyscreenshot" timeout=False>