Pyamg不工作(没有名为“Pyamg.amg_core.evolution_strength”的模块)

2024-06-01 14:23:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用PyAMG(https://pyamg.readthedocs.io/en/latest/#)。
我使用(pip install pyamg)安装它
我在windows中使用spyder。当我要导入它时,它会给出错误信息
我运行它的示例:

import pyamg
import numpy as np
A = pyamg.gallery.poisson((500,500), format='csr')  # 2D Poisson problem on 500x500 grid
ml = pyamg.ruge_stuben_solver(A)                    # construct the multigrid hierarchy
print(ml)                                           # print hierarchy information
b = np.random.rand(A.shape[0])                      # pick a random right hand side
x = ml.solve(b, tol=1e-10)                          # solve Ax=b to a tolerance of 1e-10
print("residual: ", np.linalg.norm(b-A*x))          # compute norm of residual vector

错误是:
导入pyamg.amg_核心

文件“C:\Users\Admin\AppData\Local\Programs\Spyder\pkgs\pyamg\amg\u core\uem>init\uuu.py”,第5行,在 来源:进化与力量导入*

ModuleNotFoundError:没有名为'pyamg.amg\u core.evolution\u strength'的模块

我如何解决这个问题

提前谢谢


Tags: ofhttpscoreimportnormhierarchynprandom