Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

networkx shows random_state_index is incorrect

I am trying to draw simple graph with networkx and Python.

This is my code:

import networkx as nx
import matplotlib.pyplot as plt
G = nx.complete_graph(5)
nx.draw(G, with_labels=True, font_weight='bold')
plt.show()

but I am getting the error

Message=random_state_index is incorrect
Source=***\PythonTest.py
StackTrace:
File "***\PythonTest.py", line 15, in <module>
  nx.draw(G, with_labels=True)

Python 3.7 64bit

OS Windows

networkx 2.2 ,2.3 or 2.5 have the same problem.

like image 368
S.Shafie Avatar asked Apr 02 '21 14:04

S.Shafie


4 Answers

The problem is resolved if you update the latest decorator 5.0.9 version (June 2021)

pip install decorator==5.0.9 then reboot

like image 130
Aqua_George Avatar answered Oct 11 '22 11:10

Aqua_George


It looks like the issue MAY be due to a new release of the decorator module. See here: https://github.com/networkx/networkx/issues/4718

Can you downgrade your version of decorator?

like image 32
Frodnar Avatar answered Oct 11 '22 09:10

Frodnar


Open anaconda prompt and type

conda update --all

.. and Enter, it installs stable packages which are most compatible.

like image 41
user17099453 Avatar answered Oct 11 '22 10:10

user17099453


Just update the decorater and networkx versions:

pip install --user decorator==4.3.0 # (ignore waring for availability of newer version)

pip install --user networkx==2.3

This worked for me.

like image 21
Kishan Kumar Avatar answered Oct 11 '22 09:10

Kishan Kumar