diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2016-05-14 22:53:24 +0200 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@gmail.com> | 2016-05-14 22:53:24 +0200 |
commit | 05deb50d025943a742ac6017598b42987657af17 (patch) | |
tree | dfc40d749f6858a2d9fd5f8bf4c72665d76316d0 | |
parent | 43e061b6bd67ff2d04c3891e2f4dd4d6dd683b26 (diff) | |
download | numpy-05deb50d025943a742ac6017598b42987657af17.tar.gz |
MAINT: clearer exception message when importing multiarray fails.
This regularly confuses users, see for example gh-5529.
The path via which the multiarray import is reached has changed a few times
in the last couple of years, but multiarray is always the first extension
module to be imported, so this looks like a reasonable place to add the
message.
-rw-r--r-- | numpy/core/__init__.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py index e8719ca75..1ac850002 100644 --- a/numpy/core/__init__.py +++ b/numpy/core/__init__.py @@ -11,7 +11,18 @@ for envkey in ['OPENBLAS_MAIN_FREE', 'GOTOBLAS_MAIN_FREE']: if envkey not in os.environ: os.environ[envkey] = '1' env_added.append(envkey) -from . import multiarray + +try: + from . import multiarray +except ImportError: + msg = """ +Importing the multiarray numpy extension module failed. Most +likely you are trying to import a failed build of numpy. +If you're working with a numpy git repo, try `git clean -xdf` (removes all +files not under version control). Otherwise reinstall numpy. +""" + raise ImportError(msg) + for envkey in env_added: del os.environ[envkey] del envkey |