Skip to content

Commit 0df1ee0

Browse files
committed
BUG: matplotlib is supposed to be optional
This code was failing to find matplotlib and the first import was silently continuing, but then the second call that requires matplotlib began failing.
1 parent 4e3d750 commit 0df1ee0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nipype/pipeline/plugins/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,15 @@ def create_pyscript(node, updatehash=False, store_exception=True):
112112
# create python script to load and trap exception
113113
cmdstr = """import os
114114
import sys
115+
116+
can_import_matplotlib = True #Silently allow matplotlib to be ignored
115117
try:
116118
import matplotlib
117119
matplotlib.use('%s')
118120
except ImportError:
121+
can_import_matplotlib = False
119122
pass
123+
120124
from nipype import config, logging
121125
from nipype.utils.filemanip import loadpkl, savepkl
122126
from socket import gethostname
@@ -130,7 +134,9 @@ def create_pyscript(node, updatehash=False, store_exception=True):
130134
from collections import OrderedDict
131135
config_dict=%s
132136
config.update_config(config_dict)
133-
config.update_matplotlib()
137+
## Only configure matplotlib if it was successfully imported, matplotlib is an optional component to nipype
138+
if can_import_matplotlib:
139+
config.update_matplotlib()
134140
logging.update_logging(config)
135141
traceback=None
136142
cwd = os.getcwd()

0 commit comments

Comments
 (0)