Nipype - 'networkx' has no attribute 'to_scipy_sparse_matrix'

Summary of what happened:

Hi everyone, so I’m trying to run the workflow in the tutorial

It’s all good till I get to this line:‘MultiProc’, plugin_args={‘n_procs’: 8})

Then, I get an error message about ‘networkx’ has no attribute ‘to_scipy_sparse_matrix’

Neither networkx or to_scipy_sparse_matrix appear in the code so I assume it’s an internal problem within Nipype? Does anyone know how to fix it?

I tried updating nipype and networkx but to no avail

Thanks in advance,

Command used (and if a helper script was used, a link to the helper script or the command generated):‘MultiProc’, plugin_args={‘n_procs’: 8})


nipype 1.8.6
networks 3.2.1

Relevant log outputs:

when I ran it through the cosnole I got:

Traceback (most recent call last):
File “…/shahar.bennoun/.conda/envs/abylab_fmri/lib/python3.11/site-packages/IPython/core/”, line 3526, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 1, in‘MultiProc’)
File …/shahar.bennoun/.conda/envs/abylab_fmri/lib/python3.11/site-packages/nipype/pipeline/engine/", line 638, in run, updatehash=updatehash, config=self.config)
File “…/shahar.bennoun/.conda/envs/abylab_fmri/lib/python3.11/site-packages/nipype/pipeline/plugins/”, line 121, in run
File “…/shahar.bennoun/.conda/envs/abylab_fmri/lib/python3.11/site-packages/nipype/pipeline/plugins/”, line 437, in _generate_dependency_list
self.depidx = nx.to_scipy_sparse_matrix(
AttributeError: module ‘networkx’ has no attribute ‘to_scipy_sparse_matrix’

Weird enough, when I ran the code as whole I got a different message:

Traceback (most recent call last):
File “…/shahar.bennoun/PycharmProjects/Bunshin_jutsu/”, line 41, in
extract = Node(ExtractROI(t_min=4, t_size=-1, output_type=‘NIFTI’),
File “…/shahar.bennoun/.conda/envs/bunshin/lib/python3.11/site-packages/nipype/interfaces/fsl/”, line 171, in init
super(FSLCommand, self).init(**inputs)
File “…/shahar.bennoun/.conda/envs/bunshin/lib/python3.11/site-packages/nipype/interfaces/base/”, line 629, in init
super(CommandLine, self).init(**inputs)
File “…/shahar.bennoun/.conda/envs/bunshin/lib/python3.11/site-packages/nipype/interfaces/base/”, line 189, in init
BaseInterface._etelemetry_version_data = check_latest_version() or “n/a”
File “…/shahar.bennoun/.conda/envs/bunshin/lib/python3.11/site-packages/nipype/”, line 85, in check_latest_version
import etelemetry
File “…/shahar.bennoun/.conda/envs/bunshin/lib/python3.11/site-packages/etelemetry/”, line 1, in
from .client import get_project, check_available_version
File “…/shahar.bennoun/.conda/envs/bunshin/lib/python3.11/site-packages/etelemetry/”, line 4, in
import ci
ModuleNotFoundError: No module named ‘ci’

You are running nipype through multiple environments. The networkx issue was fixed in 1.8.6:

It looks like the abylab_fmri environment just needs to update nipype.

For the bunshin environment, it looks like you somehow don’t have the whole dependency tree installed. I would probably delete this environments and start from scratch. Once you lose environment consistency, it’s generally not worth trying to fix.

1 Like

First of all thanks so much for the reply!

I did not notice I pasted the error messages from both condas.

When I ran the code in ‘bunshin’ console I got the exact same error message. That is probably because ‘bunshin’ is actually a clone of ‘abylab’ conda, with the only difference being nipype updated in ‘bunshin’…