简体   繁体   中英

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". "MESHMODEL", in turn, imports RegularGridInterpolator from scipy.interpolate .

When I run the program in the mac terminal, using "python BASEchange.py -h", I get the following error:

ImportError: cannot import name RegularGridInterpolator

I have scipy intalled via pip.

Here are the first lines form 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. Note that RegularGridInterpolator are only supported from version 0.14.

Do the following.

upgrade your pip

  • for Python 3:

    python3 -m pip install --upgrade pip

  • for Python 2:

    python2 -m pip install --upgrade pip

Then Follow the commands from here to install scipy:

python -m pip install --user scipy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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