ponty / pyscreenshot

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

Exception on Ubuntu 'module' has no attribute 'App' #28

Closed willmcgugan closed 8 years ago

willmcgugan commented 8 years ago

There seems to be an issue with the wx back end on Ubuntu. I get the following traceback:

$ python -m pyscreenshot.examples.showgrabfullscreen
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/examples/showgrabfullscreen.py", line 5, in <module>
    im=ImageGrab.grab()
  File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/__init__.py", line 61, in grab
    return _grab(to_file=False, childprocess=childprocess, backend=backend, bbox=bbox)
  File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/__init__.py", line 46, in _grab
    return _grab_simple(to_file, backend, bbox, filename)
  File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/__init__.py", line 22, in _grab_simple
    return backend_obj.grab(bbox)
  File "/usr/local/lib/python2.7/dist-packages/pyscreenshot/plugins/wxscreen.py", line 21, in grab
    self.app = wx.App()
AttributeError: 'module' object has no attribute 'App'
ponty commented 8 years ago

I have no such problem on Ubuntu 15.10.

You can try these tests:

$ python -m pyscreenshot.check.versions
pyscreenshot         0.4
wx                   3.0.2.0
pygtk                2.28.6
pyqt                 not implemented
scrot                0.8
imagemagick          6.8.9
$ python -m pyscreenshot.check.showall
grabbing by wx
grabbing by pygtk
grabbing by pyqt
grabbing by scrot
grabbing by imagemagick
[<PIL.Image._ImageCrop image mode=RGB size=300x200 at 0x7F07FB4A6B50>, <PIL.PngImagePlugin.PngImageFile image mode=RGB size=300x200 at 0x7F07EC074990>, <PIL.Image._ImageCrop image mode=RGB size=300x200 at 0x7F07DC495BD0>, <PIL.Image._ImageCrop image mode=RGB size=300x200 at 0x7F07DC495C90>, <PIL.PngImagePlugin.PngImageFile image mode=RGB size=300x200 at 0x7F07DC495CD0>]
willmcgugan commented 8 years ago

I think my installation of wx was broken. After uninstalling and re-installing wx, it worked.