When you run the .py script, an error occurs:

There was an error: no display name and no $DISPLAY environment variable. 

What have I done wrong? And how to fix it?

  • Look pozh. here stackoverflow.com/questions/2801882/… . Mine swine problem - Chubatiy
  • @Chubatiy I'm not strong in English. - JamesJGoodwin
  • Add import matplotlib matplotlib.use('Agg') to the top of the script - Chubatiy
  • @Chubatiy ImportError: No module named matplotlib, and if I try to install it via pip install, I get an error: Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-gDvDOS/matplotlib 16
  • I put the module through apt-get install python-matplotlib , and again I get the error no display name and no $DISPLAY environment variable. - JamesJGoodwin

1 answer 1

The script tries to display something on the screen (for example, GUI) and cannot find it ( $DISPLAY environment variable is not set correctly), for example, because X redirection during ssh / launch from cron is not configured or X server is not started /installed.