我正在尝试使用适用于Python的NetworkX库来计算多个网络的分类性。
当我运行以下代码时,
r_pearson = []
for graph in graphs:
r.append(nx.degree_pearson_correlation_coefficient(graph))
print(r_pearson)
我收到此错误:
> ---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\networkx\algorithms\assortativity\correlation.py in degree_pearson_correlation_coefficient(G, x, y, weight, nodes)
133 try:
--> 134 import scipy.stats as stats
135 except ImportError:
~\Anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
366
--> 367 from .stats import *
368 from .distributions import *
~\Anaconda3\lib\site-packages\scipy\stats\stats.py in <module>
172 import scipy.special as special
--> 173 from . import distributions
174 from . import mstats_basic
~\Anaconda3\lib\site-packages\scipy\stats\distributions.py in <module>
9
---> 10 from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
11 rv_frozen)
~\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py in <module>
23 # for root finding for discrete distribution ppf, and max likelihood estimation
---> 24 from scipy import optimize
25
~\Anaconda3\lib\site-packages\scipy\optimize\__init__.py in <module>
386 from .optimize import *
--> 387 from ._minimize import *
388 from ._root import *
~\Anaconda3\lib\site-packages\scipy\optimize\_minimize.py in <module>
29 from ._trustregion_exact import _minimize_trustregion_exact
---> 30 from ._trustregion_constr import _minimize_trustregion_constr
31
~\Anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\__init__.py in <module>
3
----> 4 from .minimize_trustregion_constr import _minimize_trustregion_constr
5
~\Anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\minimize_trustregion_constr.py in <module>
3 import numpy as np
----> 4 from scipy.sparse.linalg import LinearOperator
5 from .._differentiable_functions import VectorFunction
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
116 from .interface import *
--> 117 from .eigen import *
118 from .matfuncs import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
10
---> 11 from .arpack import *
12 from .lobpcg import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
21
---> 22 from .arpack import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py in <module>
44
---> 45 from . import _arpack
46 import numpy as np
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-159-577d6fa80c45> in <module>
1 r_pearson = []
2 for graph in graphs:
----> 3 r.append(nx.degree_pearson_correlation_coefficient(graph))
4 r_pearson
~\Anaconda3\lib\site-packages\networkx\algorithms\assortativity\correlation.py in degree_pearson_correlation_coefficient(G, x, y, weight, nodes)
135 except ImportError:
136 raise ImportError(
--> 137 "Assortativity requires SciPy: http://scipy.org/ ")
138 xy = node_degree_xy(G, x=x, y=y, nodes=nodes, weight=weight)
139 x, y = zip(*xy)
ImportError: Assortativity requires SciPy: http://scipy.org
我拥有最新版本的Numpy和Scipy,并且正在使用python版本3.6.8和Anaconda 4.6.4。我尝试重新安装Anaconda,然后更新必要的程序包。当我尝试运行某些NetworkX功能(例如kamada_kawai_layout和degree_pearson_correlation_coefficient)时,出现此错误。 NetworkX的早期版本似乎没有引发此错误,但是不幸的是缺少我喜欢使用的功能,例如kamada_kawai_layout等。有什么建议吗?