johnyf / nx2tikz

Export NetworkX graphs to TikZ directly
Other
29 stars 2 forks source link

example.py error #2

Closed david-kooi closed 2 weeks ago

david-kooi commented 5 years ago

Trying to run the example using python2.7 and I get this: Perhaps not supported with 2.7?


dkooi@rse-mac-2:~/Workspace/nx2tikz/examples$ python example.py 
Traceback (most recent call last):
  File "example.py", line 34, in <module>
    write_tikz()
  File "example.py", line 8, in write_tikz
    tikz = nx2tikz.dumps_tikz(g)
  File "build/bdist.macosx-10.14-intel/egg/nx2tikz/nx2tikz.py", line 12, in dumps_tikz
AttributeError: 'DiGraph' object has no attribute 'nodes_iter'```
johnyf commented 3 years ago

This error is due to API changes in networkx >= 2.0.0. nx2tikz == 0.1.0 requires networkx < 2.0.0.

1 concerns the update of nx2tikz to the API of networkx >= 2.0.0.

Also, nx2tikz == 0.1.0 is compatible with only Python 2.7, not Python 3, due to the sequence \u being present in (default) string literals and not followed by a unicode character code: https://github.com/johnyf/nx2tikz/blob/bcb9767cd87aa215f5c892feb0f6fc80cc09f56e/nx2tikz/nx2tikz.py#L68-L73

johnyf commented 3 years ago

Another reason for incompatibility with Python 2.7 is the way of writing to a pipe:

https://github.com/johnyf/nx2tikz/blob/e114a90f12a63e61a4daf3fae3ea5111f4975302/nx2tikz/nx2tikz.py#L111-L112

As of e114a90f12a63e61a4daf3fae3ea5111f4975302, I added a constraint to the required version of networkx in install_requires within setup.py, and Trove classifiers that signify compatibility with only Python 2. I tagged this commit as v0.1.0.

Also, I pushed branch dev, where I have updated nx2tikz to be compatible with networkx >= 2.0.0 and networkx < 2.0.0, and with Python 2.7, 3.6, 3.7, 3.8, and 3.9.

johnyf commented 2 weeks ago

Thank you for reporting this error. Branch main has been updated to work with Python 3.13 and networkx >= 2.0.0.