首页 > 解决方案 > 从 scipy.interpolate 导入 RegularGridInterpolator 时出错

问题描述

我在尝试为大学课程运行代码时遇到问题。主文件 BASEchange.py 尝试导入 2 个名为“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

提前致谢!

标签: pythonscipy

解决方案


你可能有错误的 scipy 版本。请注意,RegularGridInterpolator仅支持version 0.14.

请执行下列操作。

升级你的点子

  • 对于 Python 3:

    python3 -m pip install --upgrade pip

  • 对于 Python 2:

    python2 -m pip install --upgrade pip

然后按照这里的命令安装 scipy:

python -m pip install --user scipy


推荐阅读