Solution for random_state_index is incorrect in networkx

random_state_index is incorrect in networkx

If you are having trouble with the error random_state_index is incorrect in Networkx, this article is for you. We can use stable versions of the decorator to work around this problem. Check out the information below. We will provide you with all possible solutions to solve this error.

Why does this error occur?

NetworkX is a Python package that supports the ability to plot, manipulate data, and read multi-level graphs. It also helps you develop and influence high-quality networks’ architecture, movement, and functionality. This is a free python package and was released under the new BSD license.

This issue is related to the version of the decorator module integrated into Networkx. In versions 5.0.* up to version 5.0.5, which started breaking things in Networkx, when you use one of these versions, the error “NetworkXError: random_state_index is incorrect” will likely occur in your project. Likely, these versions of the decorator are not correctly integrated into Networkx.

You can find more information about this issue on github Networkx Issue #4718.

How to solve the error “random_state_index is incorrect” in Networkx

Now, you can follow the methods below for the solution for random_state_index is incorrect in Networkx.

Upgrade version for decorator

In the first approach, we will upgrade the version of the module decorator with the following command:

pip install decorator==<version>

In the above command, <version> is the specific version you want to install for the decorator module

Networkx has released version 5.0.6, which fixes some of the issues found in versions 5.0.0 to 5.0.5. 

You can install version 5.0.6 for your project. However, the latest version by the time of this article is 5.1.1 (It may be different by the time you are reading). We recommend that you install this latest version.

::install version 5.0.6
pip install decorator==5.0.6

::install version 5.1.1
pip install decorator==5.1.1

Downgrade version of decorator

Contrary to the above approach. In this approach, we will try to downgrade the module decorator.

When downgrading, we will be interested in stable versions of module A. In this article, we recommend you use version 4.3.

pip install decorator==4.3

A note as follows: If your project uses the matplotlib module, you can try to downgrade the version of matplotlib along with the decorator module if the error persists. E.g.:

pip install matplotlib==3.5.1


In summary, that’s all we want to talk about the method to the error random_state_index is incorrect in Networkx. Please use more stable versions of the decorator to avoid this kind of error as well as other unexpected errors. Hopefully, the information we provide in this post is helpful to you.

Maybe you are interested:

3 thoughts on “Solution for random_state_index is incorrect in networkx

  1. hello,

    I read your article avout resolving NetworkXError: random_state_index is incorrect.

    I have a bit of diffreent situation: Spyder version is 3.8. I cannot install later version than this one because I am still using Windows 7.

    I would like you to help me about what version of decorator do I need to install?

    Thank you in advance!

    1. Hi Wallal, thank you for your interest in the article.

      First, you need to check the version of the decorator you are using to see if it has been revoked (Yanked). It could be the main cause of your error.

      I recommend installing the latest version of the decorator module. You can find the release history here: According to the instructions in the documentation, the latest version still supports python from version 3.5, so I think the real problem is not with the python version you are using.

Leave a Reply

Your email address will not be published. Required fields are marked *