@@ -91,13 +91,6 @@ def report_nodes_not_run(notrun):
91
91
'Check log for details' ))
92
92
93
93
94
- def write_matplotlibrc (batch_dir ):
95
- """Set the matplotlib backend in a local rc file."""
96
- backend = nipype .config .get ("execution" , "matplotlib_backend" )
97
- with open (os .path .join (batch_dir , "matplotlibrc" ), "w" ) as fid :
98
- fid .write ("backend : %s" % backend )
99
-
100
-
101
94
def create_pyscript (node , updatehash = False , store_exception = True ):
102
95
# pickle node
103
96
timestamp = strftime ('%Y%m%d_%H%M%S' )
@@ -111,12 +104,14 @@ def create_pyscript(node, updatehash=False, store_exception=True):
111
104
batch_dir = os .path .join (node .base_dir , 'batch' )
112
105
if not os .path .exists (batch_dir ):
113
106
os .makedirs (batch_dir )
114
- write_matplotlibrc (batch_dir )
115
107
pkl_file = os .path .join (batch_dir , 'node_%s.pklz' % suffix )
116
108
savepkl (pkl_file , dict (node = node , updatehash = updatehash ))
109
+ mpl_backend = nipype .config .get ("execution" , "matplotlib_backend" )
117
110
# create python script to load and trap exception
118
111
cmdstr = """import os
119
112
import sys
113
+ import matplotlib
114
+ matplotlib.use('%s')
120
115
from nipype import config, logging
121
116
from nipype.utils.filemanip import loadpkl, savepkl
122
117
from socket import gethostname
@@ -162,7 +157,7 @@ def create_pyscript(node, updatehash=False, store_exception=True):
162
157
report_crash(info['node'], traceback, gethostname())
163
158
raise Exception(e)
164
159
"""
165
- cmdstr = cmdstr % (pkl_file , batch_dir , node .config , suffix )
160
+ cmdstr = cmdstr % (mpl_backend , pkl_file , batch_dir , node .config , suffix )
166
161
pyscript = os .path .join (batch_dir , 'pyscript_%s.py' % suffix )
167
162
fp = open (pyscript , 'wt' )
168
163
fp .writelines (cmdstr )
0 commit comments