jgerstmayr / EXUDYN

Multibody Dynamics Simulation: Rigid and flexible multibody systems
https://www.youtube.com/channel/UCsQD2bIPBXB_4J23WtqKkVw/playlists
Other
166 stars 23 forks source link

Unable to draw graph of the system #26

Closed dummifiedme closed 2 years ago

dummifiedme commented 2 years ago

While trying to draw graph for the system in the example, with the code DrawSystemGraph(mbs, useItemTypes=True) python throws an error:

AttributeError                            Traceback (most recent call last)
      [241]  mbs.Assemble()
--> [242]  DrawSystemGraph(mbs, useItemTypes=True) #draw nice graph of system
    [243] simulationSettings = exu.SimulationSettings()

File ~/.local/lib/python3.10/site-packages/exudyn/utilities.py:975, in DrawSystemGraph(mbs, showLoads, showSensors, useItemNames, useItemTypes)
    [971](file:///home/prestige/.local/lib/python3.10/site-packages/exudyn/utilities.py?line=970) sensorsToItems=[]   #maps mbs-sensor numbers to item numbers
    [973](file:///home/prestige/.local/lib/python3.10/site-packages/exudyn/utilities.py?line=972) objectNodeColor = 'navy' #color for edges between nodes and objects, to be highlighted
--> [975](file:///home/prestige/.local/lib/python3.10/site-packages/exudyn/utilities.py?line=974) G = nx.Graph()
    [977](file:///home/prestige/.local/lib/python3.10/site-packages/exudyn/utilities.py?line=976) showLegend = False
    [978](file:///home/prestige/.local/lib/python3.10/site-packages/exudyn/utilities.py?line=977) addItemNames = False #Object, Node, ... not added but legend added

AttributeError: module 'networkx' has no attribute 'Graph'

How can I fix this error?

jgerstmayr commented 2 years ago

I cannot reproduce your error, using Python3.10 (Windows) and the current networkx with pip installer. It seems that networkx is not installed properly. Try to test simple examples of the networkx package (https://networkx.org/documentation/stable/tutorial.html). Did you install with "pip install networkx" ?