使用networkx时,报错random_state_arg = args[random_state_index]IndexError: tuple index out of range解决

在使用networkx时,有时候会出现报错

random_state_arg = args[random_state_index]

IndexError: tuple index out of range

这是因为decorator版本较高,与networkx不匹配,只需要降低decorator的版本,一般来说如下即可:

pip install decorator==4.4.2

相关:Networkx是一个Python包,用于创建、操作和研究复杂网络的结构、动态和功能。参见:https://networkx.github.io完整的文档。

然后这样了,安装成功了。

>>
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting decorator==4.4.2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ed/1b/72a1821152d07cf1d8b6fce298aeb06a7eb90f4d6d41acec9861e7cc6df0/decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
DEPRECATION: pyodbc 4.0.0-unsupported has a non-standard version number. pip 24.1 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pyodbc or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: decorator
  Attempting uninstall: decorator
    Found existing installation: decorator 5.0.6
    Uninstalling decorator-5.0.6:
      Successfully uninstalled decorator-5.0.6
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spyder 4.2.5 requires pyqt5<5.13, which is not installed.
spyder 4.2.5 requires pyqtwebengine<5.13, which is not installed.
Successfully installed decorator-4.4.2

续写:

在降低decorator版本之后,依旧不显示networkx的绘图,有可能时networkx和matplotlib版本不兼容,而且我使用的时anoconda3的base python3.8,这时候只需要更新conda中networkx和matplotlib到最新版本即可。

在conda环境中,要更新networkx和matplotlib(通常用于绘图,缩写为plt)到最新版本,使用以下命令:

conda update networkx
conda update matplotlib

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值