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
Summary
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:
- RuntimeWarning: Enable tracemalloc to get the object allocation traceback
- ImportError: cannot import name ‘force_text’ from ‘django.utils.encoding’

My name’s Christopher Gonzalez. I graduated from HUST two years ago, and my major is IT. So I’m here to assist you in learning programming languages. If you have any questions about Python, JavaScript, TypeScript, Node.js, React.js, let’s contact me. I will back you up.
Name of the university: HUST
Major: IT
Programming Languages: Python, JavaScript, TypeScript, Node.js, React.js
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!
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: https://pypi.org/project/decorator/#history. 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.