[Scipy-svn] r5003 - trunk/scipy/cluster

scipy-svn@scip... scipy-svn@scip...
Thu Nov 6 07:24:47 CST 2008


Author: cdavid
Date: 2008-11-06 07:24:44 -0600 (Thu, 06 Nov 2008)
New Revision: 5003

Modified:
   trunk/scipy/cluster/hierarchy.py
Log:
Catch RuntimeError when importing matplotlib.pylab to handle cases where mpl is there but no X server is available.

Modified: trunk/scipy/cluster/hierarchy.py
===================================================================
--- trunk/scipy/cluster/hierarchy.py	2008-11-06 11:57:21 UTC (rev 5002)
+++ trunk/scipy/cluster/hierarchy.py	2008-11-06 13:24:44 UTC (rev 5003)
@@ -1440,8 +1440,13 @@
 try:
 
     import matplotlib
-    import matplotlib.pylab
-    import matplotlib.patches
+    try:
+        import matplotlib.pylab
+        import matplotlib.patches
+    except RuntimeError, e:
+        # importing matplotlib.pylab can fail with a RuntimeError if installed
+        # but the graphic engine cannot be initialized (for example without X)
+        raise ImportError("Could not import matplotib (error was %s)" % str(e))
     #import matplotlib.collections
     _mpl = True
 



More information about the Scipy-svn mailing list