Commit 77a829e9eb2c9c8d9712791d1396e919608d7733
1 parent
6ed8241e
Make matplotlib optional in show_viscube.py (#3065)
Showing
1 changed file
with
7 additions
and
1 deletions
examples/show_viscube.py
| ... | ... | @@ -21,7 +21,13 @@ |
| 21 | 21 | import sys |
| 22 | 22 | import gammalib |
| 23 | 23 | import cscripts |
| 24 | -import matplotlib.pyplot as plt | |
| 24 | +try: | |
| 25 | + import matplotlib.pyplot as plt | |
| 26 | + plt.figure() | |
| 27 | + plt.close() | |
| 28 | +except (ImportError, RuntimeError): | |
| 29 | + print('This script needs the "matplotlib" module') | |
| 30 | + sys.exit() | |
| 25 | 31 | |
| 26 | 32 | |
| 27 | 33 | # =========================== # | ... | ... |