theochem / horton

HORTON: Helpful Open-source Research TOol for N-fermion systems
http://theochem.github.io/horton/
GNU General Public License v3.0
94 stars 40 forks source link

Matplotlib backends need to be handled better #219

Closed matt-chan closed 7 years ago

matt-chan commented 7 years ago

It's driving me crazy. We should find a more permanent solution to the matplotlib backend problem. It actually segfaults in Conda if we use our current code.

I found something like this on stackoverflow:

import matplotlib
gui_env = ['TKAgg','GTKAgg','Qt4Agg','WXAgg']
for gui in gui_env:
    try:
        print "testing", gui
        matplotlib.use(gui,warn=False, force=True)
        from matplotlib import pyplot as plt
        break
    except:
        continue
print "Using:",matplotlib.get_backend()

It might work.

Or we can just remove the tests that do plotting. Not sure if that's a good idea though.

tovrstra commented 7 years ago

Would the following trick work?:

https://github.com/hpcugent/easybuild-easyconfigs/blob/master/easybuild/easyconfigs/h/horton/horton-2.0.0-intel-2015b-Python-2.7.10-HDF5-1.8.15-patch1-serial.eb

i.e. this part

runtest = ' '.join([
    'export MATPLOTLIBRC=$PWD;',
    'echo "backend: agg" > $MATPLOTLIBRC/matplotlibrc;',
    '%s python setup.py build_ext -i; ' % prebuildopts,
    'nosetests -v',
])
matt-chan commented 7 years ago

Yep, but I think users would still run into the same problem if they weren't doing the tests...

On Mon, 3 Apr 2017 at 11:29 Toon Verstraelen notifications@github.com wrote:

Would the following trick work?:

https://github.com/hpcugent/easybuild-easyconfigs/blob/master/easybuild/easyconfigs/h/horton/horton-2.0.0-intel-2015b-Python-2.7.10-HDF5-1.8.15-patch1-serial.eb

i.e. this part

runtest = ' '.join([ 'export MATPLOTLIBRC=$PWD;', 'echo "backend: agg" > $MATPLOTLIBRC/matplotlibrc;', '%s python setup.py build_ext -i; ' % prebuildopts, 'nosetests -v', ])

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/theochem/horton/issues/219#issuecomment-291231489, or mute the thread https://github.com/notifications/unsubscribe-auth/AA_-Nfvv3Vm_D-9BuDb-qx9hBcIVtRytks5rsTqIgaJpZM4Mx6Vg .

-- Matt

Sent from my phone

tovrstra commented 7 years ago

I think matplotlib is configured incorrectly in your case. The default configuration of matplotlib assumes some GUI environment is available. If that is not the case, you should switch to a non-GUI backend before using matplotlib. Most users don't have this problem because the default GUI backend will just work on a desktop. (The snippet you mentioned only loops over GUI backends, which may not be what you want.)

tovrstra commented 7 years ago

I'm going to close this. This is not a HORTON but a Matplotlib issue. As long as Matplotlib developers decide that the default backend requires X, there is little we can do. There is no point in changing the Matplotlib backend from HORTON because that could result in undesired behavior for those users who still expect the default backend to be used.