从scipy.interpolate导入RegularGridInterpolator时出错

2024-06-28 10:51:40 发布

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

我在大学尝试运行课程代码时遇到问题。主文件BASEchange.py尝试导入名为“NODE”和“MESHMODEL”的两个模块。“MESHMODEL”依次从scipy.interpolate导入RegularGridInterpolator

当我在mac终端中使用“python BASEchange.py-h”运行程序时,我得到以下错误:

ImportError:无法导入名称RegularGridInterpolator

我通过pip输入了scipy

以下是meshModel.py的第一行:

import sys, os, platform, subprocess, stat, re, abc, math, linecache, shutil
import numpy as np
from scipy.interpolate import RegularGridInterpolator
from scipy import interpolate
from scipy.sparse import csc_matrix, lil_matrix, tril, find
from scipy.sparse.csgraph import reverse_cuthill_mckee

提前谢谢


Tags: 文件代码frompyimportnodescipymatrix
1条回答
网友
1楼 · 发布于 2024-06-28 10:51:40

您可能使用了错误的scipy版本。请注意RegularGridInterpolator仅受version 0.14.的支持

执行以下操作

升级你的pip

  • 对于Python 3:

    python3 -m pip install upgrade pip

  • 对于Python 2:

    python2 -m pip install upgrade pip

然后按照here中的命令安装scipy:

python -m pip install user scipy

相关问题 更多 >