Skip to content

AttributeError: 'module' object has no attribute 'write_dot' #1350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheChymera opened this issue Feb 5, 2016 · 16 comments
Closed

AttributeError: 'module' object has no attribute 'write_dot' #1350

TheChymera opened this issue Feb 5, 2016 · 16 comments

Comments

@TheChymera
Copy link
Collaborator

I am trying to run this pipeline and I am getting this error message:

/usr/lib64/python2.7/site-packages/nipy/labs/glm/glm.py:9: FutureWarning: Module nipy.labs.utils.routines deprecated, will be removed
  from ..utils import mahalanobis
/usr/lib64/python2.7/site-packages/nipype/interfaces/nipy/model.py:18: FutureWarning: Module nipy.labs.glm deprecated, will be removed. Please use nipy.modalities.fmri.glm instead.
  import nipy.labs.glm.glm as GLM
/usr/lib64/python2.7/site-packages/nipype/interfaces/base.py:419: UserWarning: Input tr requires inputs: slice_times
  warn(msg)
/usr/lib64/python2.7/site-packages/nipype/interfaces/base.py:419: UserWarning: Input slice_info requires inputs: slice_times
  warn(msg)
160205-22:03:39,570 workflow INFO:
         Creating detailed dot file: /home/chymera/NIdata/ofM.dr/FSL_GLM_work/graph_detailed.dot
Traceback (most recent call last):
  File "glm.py", line 166, in <module>
    fsl_glm(workflow_base="~/NIdata/ofM.dr/", functional_scan_type="7_EPI_CBV", structural_scan_type="T2_TurboRARE>", experiment_type="<ofM>", omit_ID=["20151027_121613_4013_1_1"])
  File "glm.py", line 162, in fsl_glm
    pipeline.write_graph(graph2use="flat")
  File "/usr/lib64/python2.7/site-packages/nipype/pipeline/engine.py", line 558, in write_graph
    format=format, simple_form=simple_form)
  File "/usr/lib64/python2.7/site-packages/nipype/pipeline/utils.py", line 905, in export_graph
    nx.write_dot(pklgraph, outfname)
AttributeError: 'module' object has no attribute 'write_dot'

It seems to be due to this line. And if I cmment it, the pipeline works. This happens both with release 0.11.0 and with the live nipype version from github. I have matplotlib. Any ideas what might be the problem?

@mwaskom
Copy link
Member

mwaskom commented Feb 5, 2016

nx is NetworkX, but for write_dot to work you need either pygraphviz or pydot installed, as per here. Do you have one of those libraries?

@TheChymera
Copy link
Collaborator Author

@mwaskom I have:

*networkx-1.11
*pydot-1.0.28-r2
*pygraphwiz-1.3.1

MAybe I need pydotplus instead? Prov uses it for testing.

TheChymera pushed a commit to IBT-FMI/SAMRI that referenced this issue Feb 8, 2016
@polosecki
Copy link

Same issue here in nipype when using write_graph with the following libraries installed:
graphviz (0.4.9)
pygraphviz (1.3.1)
pydot (1.0.28)
networkx (1.11)
Error can be also reproduced by typing:

import networkx as NX
G=NX.grid_2d_graph(5,5)  # 5x5 grid
NX.write_dot(G,"grid.dot")

which produces the error

Traceback (most recent call last):

  File "<ipython-input-4-742fbc2aa48b>", line 1, in <module>
    NX.write_dot(G,"grid.dot")

AttributeError: 'module' object has no attribute 'write_dot'

@mwaskom
Copy link
Member

mwaskom commented Feb 8, 2016

Not sure what the problem is, but it doesn't sound like a nipype issue per se.

@satra
Copy link
Member

satra commented Feb 8, 2016

this example suggests that the above should work:

https://networkx.github.io/documentation/latest/examples/pygraphviz/write_dotfile.html

perhaps its a version issue with networkx, we should track this down.

@polosecki
Copy link

Yes, it does seems as if, even though Python recognizes all the packages as installed, somehow networkx doesn't acknowledge it and that affects nipype. I tried uninstalling and reinstalling all these packages, which happens successfully, but doesn't correct the issue.
All suggestions are welcome.
Thank you!

@mwaskom
Copy link
Member

mwaskom commented Feb 8, 2016

I would suggest opening an issue with networkx, as it is likely that they will be able to help you debug the problem.

@polosecki
Copy link

I just opened an issue on networkx, but in the meantime I found a workaround that I thought worth sharing:
1-Install pydotplus (i.e. pip install pidotplus)
2-In nipype/pipeline/utils.py replace line 905 nx.write_dot(pklgraph, outfname) by nx.drawing.nx_pydot.write_dot(pklgraph, outfname)
Now my dot files are generated just fine.

@polosecki
Copy link

It seems my workaround is the way to go for networkx-1.11 and later
networkx/networkx#1984

@satra
Copy link
Member

satra commented Feb 8, 2016

@polosecki - could you please submit a PR that implements your work around after a version check on networkx?

@polosecki
Copy link

@satra I was meaning to do it but didn't quite know how since I had never contributed to a larger project. I'm happy that nipype is the first one. PR submitted! :)

@TheChymera
Copy link
Collaborator Author

So pydotplus is a mandatory (in as far as one wants dot files) nipype dependency now, yes?

@polosecki
Copy link

It is, right?, since it is imported in the networkx.drawing function called by nipype's write_graph.

@pinkesh
Copy link

pinkesh commented Jun 27, 2016

Thanks polosecki your solution works for me

@jolespin
Copy link

jolespin commented Feb 7, 2017

Was this fixed? I just encountered this error as well with version 1.11

@cast42
Copy link

cast42 commented Feb 1, 2018

Usign nx.nx_pydot.write_dot(G, 'tree.dot') works for me
nx.version
'2.0'

setina42 pushed a commit to setina42/SAMRI that referenced this issue Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants