pism / regional-tools

Tools for regional modeling using PISM
http://www.pism-docs.org/
5 stars 3 forks source link

on ubuntu 13.10: "cannot import name _tkagg" #3

Open bueler opened 10 years ago

bueler commented 10 years ago

This command works on one of my ubuntu machines but not the other. It is from pism/examples/jako, of course:

+ python pism_regional.py -i gr1km.nc -o jakomask.nc -x 360,382 -y 1135,1176 -b 50
Traceback (most recent call last):
  File "pism_regional.py", line 15, in <module>
    import pylab as plt
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/pylab.py", line 269, in <module>
    from matplotlib.pyplot import *
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 11, in <module>
    import matplotlib.backends.tkagg as tkagg
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/tkagg.py", line 2, in <module>
    from matplotlib.backends import _tkagg
ImportError: cannot import name _tkagg

It may be relevant that I am running python 2.7.5+ and that when I run ipython -pylab I get a message that says

Welcome to pylab, a matplotlib-based Python environment [backend: Qt4Agg].

That is, my Matplotlib does work with the Qt4Agg backend, but the gtkagg backend might not work for me.

Actually I would be happy for regional-tools to have a GUI-free mode (i.e. without needed a functioning gui to run). Or maybe that so defeats the purpose ...

ckhroulev commented 10 years ago

"regional tools" use Tk and Tkinter for the GUI, so it's not that easy to switch to the Qt4Agg backend. :-(

I agree that the "batch" mode should not even try to import GUI-related modules. This is a bug and I will fix it.

bueler commented 10 years ago

I was able to get past this. Apparently the key steps were:

I would not have tried this except I found

http://stackoverflow.com/questions/13110403/matplotlib-backend-missing-modules-with-underscore

sandwriter commented 9 years ago

Thanks, nice solution!