Re: Network Graph Fails

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Network Graph Fails

Perditorum
Hi Keith,

I recently updated my Linux Mint version to 19.3 and I got the same problem when I reinstalled Gramps. Running a Network Chart report returns an error: AttributeError: 'DiGraph' object has no attribute 'node'.
Instead of downgrading to v1.11 I've tried to solve it by checking the NetworkX migration documentation on https://networkx.github.io/documentation/stable/release/migration_guide_from_1.x_to_2.0.html:

The Graph attribute node has moved its functionality to G.nodes, so code expected to work with v2.x should use G.nodes. In fact most uses of G.node can be replaced by an idiom that works for both versions. The functionality that can’t easily is: G.node[n]. In v2.x that becomes G.nodes[n] which doesn’t work in v1.x.
Luckily you can still use G.node[n] in v2.x when you want it to be able to work with v1.x too. We have left G.node in v2.x as a transition pointer to G.nodes. We envision removing G.node in v3.x (sometime in the future).

So, I changed G.node into G.nodes everywhere in the code.
After that, I got only one error: ModuleNotFoundError: No module named 'pydot'

That's a bit strange as I had pydotplus installed already which is needed according to the Python code:

# pydotplus is needed for nx_pydot
try:
    import pydotplus
    PYDOT = True

But, after installing pydot with 'pip3 install pydot' a fresh Network Chart report was running fine.

For your convenience (and others I hope) I copied the modified file NetworkChart.py to the cloud. You can download it by using this link: https://drive.google.com/file/d/1L-ny8w_fRidR4hbdqZdElrupIWVQ_CMJ/view?usp=sharing

Installation instructions:

  1. Create a BACKUP of your Gramps tree!! And save the file on a place outside your computer.
  2. Find your plugins directory of Gramps. In Linux environments it is hidden: .gramps/gramps51/plugins/NetworkChart
  3. Copy the file NetworkChart.py to NetworkChart_orig.py. If something goes wrong you only have to rename it to the original name.
  4. Replace the file NetworkChart.py with the one I have attached to this email.
  5. Open this file with a text editor like Notepad and find the comment: # NetworkX v2 only. If you see this text the move was successful. Close the editor without saving.
  6. Open a terminal and type: $ pip3 install pydot
  7. After this the installation is ready and you can try to run Gramps with the modified plugin.

I have tried to create several reports (pdf and svg) and all were running nice without any errors.
Well, I am curious to hear your experiences.

Good luck and a Happy New Year!

NB for other readers: this is only a workaround and no extra functionality is added. Do not install it when you're Network Chart report is running fine.

Best regards,
Jan Sparreboom


Op 23-12-2019 om 21:15 schreef Keith Jacobs:
It appears that my Laptop has networkx v2 installed but the Network Graph will only work with v1,1

Would some kind sole explain how I can down grade to v1.1

I can only find python-networkx v1.11 and python3-networkx v1.11

-- Regards Keith Jacobs

--
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Reply | Threaded
Open this post in threaded view
|

Re: Network Graph Fails

Perditorum
Hi Keith,

I recently updated my Linux Mint version to 19.3 and I got the same problem when I reinstalled Gramps. Running a Network Chart report returns an error: AttributeError: 'DiGraph' object has no attribute 'node'.
Instead of downgrading to v1.11 I've tried to solve it by checking the NetworkX migration documentation on https://networkx.github.io/documentation/stable/release/migration_guide_from_1.x_to_2.0.html:

The Graph attribute node has moved its functionality to G.nodes, so code expected to work with v2.x should use G.nodes. In fact most uses of G.node can be replaced by an idiom that works for both versions. The functionality that can’t easily is: G.node[n]. In v2.x that becomes G.nodes[n] which doesn’t work in v1.x.
Luckily you can still use G.node[n] in v2.x when you want it to be able to work with v1.x too. We have left G.node in v2.x as a transition pointer to G.nodes. We envision removing G.node in v3.x (sometime in the future).

So, I changed G.node into G.nodes everywhere in the code.
After that, I got only one error: ModuleNotFoundError: No module named 'pydot'

That's a bit strange as I had pydotplus installed already which is needed according to the Python code:

# pydotplus is needed for nx_pydot
try:
    import pydotplus
    PYDOT = True

But, after installing pydot with 'pip3 install pydot' a fresh Network Chart report was running fine.

For your convenience (and others I hope) I copied the modified file NetworkChart.py to the cloud. You can download it by using this link: https://drive.google.com/file/d/1L-ny8w_fRidR4hbdqZdElrupIWVQ_CMJ/view?usp=sharing

Installation instructions:

  1. Create a BACKUP of your Gramps tree!! And save the file on a place outside your computer.
  2. Find your plugins directory of Gramps. In Linux environments it is hidden: .gramps/gramps51/plugins/NetworkChart
  3. Copy the file NetworkChart.py to NetworkChart_orig.py. If something goes wrong you only have to rename it to the original name.
  4. Replace the file NetworkChart.py with the one I have attached to this email.
  5. Open this file with a text editor like Notepad and find the comment: # NetworkX v2 only. If you see this text the move was successful. Close the editor without saving.
  6. Open a terminal and type: $ pip3 install pydot
  7. After this the installation is ready and you can try to run Gramps with the modified plugin.

I have tried to create several reports (pdf and svg) and all were running nice without any errors.
Well, I am curious to hear your experiences.

Good luck and a Happy New Year!

NB for other readers: this is only a workaround and no extra functionality is added. Do not install it when you're Network Chart report is running fine.

Best regards,
Jan Sparreboom


Op 23-12-2019 om 21:15 schreef Keith Jacobs:
It appears that my Laptop has networkx v2 installed but the Network Graph will only work with v1,1

Would some kind sole explain how I can down grade to v1.1

I can only find python-networkx v1.11 and python3-networkx v1.11

-- Regards Keith Jacobs


--
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org