简体   繁体   English

从 scipy.interpolate 导入 RegularGridInterpolator 时出错

[英]Error when importing RegularGridInterpolator from scipy.interpolate

I have a problem when trying to run a code for a course at the university.我在尝试为大学课程运行代码时遇到问题。 The main file BASEchange.py tries to import 2 modules called "NODE" and "MESHMODEL".主文件 BASEchange.py 尝试导入 2 个名为“NODE”和“MESHMODEL”的模块。 "MESHMODEL", in turn, imports RegularGridInterpolator from scipy.interpolate .反过来,“MESHMODEL”从 scipy.interpolate 导入 RegularGridInterpolator 。

When I run the program in the mac terminal, using "python BASEchange.py -h", I get the following error:当我在 mac 终端中使用“python BASEchange.py -h”运行程序时,出现以下错误:

ImportError: cannot import name RegularGridInterpolator导入错误:无法导入名称 RegularGridInterpolator

I have scipy intalled via pip.我通过 pip 安装了 scipy。

Here are the first lines form meshModel.py:这是 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

Thanks in advance!提前致谢!

You probably have the wrong version of scipy.您可能使用了错误版本的 scipy。 Note that RegularGridInterpolator are only supported from version 0.14.请注意, RegularGridInterpolator version 0.14.支持RegularGridInterpolator version 0.14.

Do the following.请执行下列操作。

upgrade your pip升级你的点子

  • for Python 3:对于 Python 3:

    python3 -m pip install --upgrade pip

  • for Python 2:对于 Python 2:

    python2 -m pip install --upgrade pip

Then Follow the commands from here to install scipy:然后按照这里的命令安装 scipy:

python -m pip install --user scipy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM