0

On a raspberry Pi running stretch lite with Python 2.7, this does not work

from PIL import Image
pic = Image.open('image1.jpg')
pic.show('title', command = 'fbi')

It gives

display-im6.q16: unsble to open X server `' @ error/display.c/DisplayImageCommand/432

but

fbi image1.jpg works fine

I also tried installing fim, tested fim and it works fine from the command line but also fails when pillow is directed to use it. I'd rather not add a ton of X server code or openCV modules just to show a pic. The only solution I have come up with is to open another terminal (alt-F2) and issue the fbi command there while the python process generates the images. Or I suppose I can try to spawn an fbi process from within the python script but then fbi blocks execution while it pauses for user input.

aquagremlin
  • 3,515
  • 2
  • 29
  • 51
  • This usually happens when you run a grafical program without an X session: on a text terminal, with `sudo` or via SSH without `-x` flag for example. – Klaus D. Mar 09 '19 at 01:24
  • `Image.show()` attempts to use whatever application is associated with images on your system to display them — which appears to be something you don't have installed (or don't have running). `fbi` doesn't require that. – martineau Mar 09 '19 at 01:49
  • ...so instead of using `pic.show()`, use the `subprocess` module to launch `fbi` to display the image after first saving it somewhere. – martineau Mar 09 '19 at 02:15

0 Answers0