# on Windows NumPy loads an important OpenBLAS-related DLL # and the code below aims to alleviate issues with DLL # path resolution portability with an absolute path DLL load from ctypes import WinDLL import glob # convention for storing / loading the DLL from # numpy/.libs/, if present libs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '.libs')) DLL_filenames = [] if os.path.isdir(libs_path): for filename in glob.glob(os.path.join(libs_path, '*openblas*dll')): # NOTE: would it change behavior to load ALL # DLLs at this path vs. the name restriction? WinDLL(os.path.abspath(filename)) DLL_filenames.append(filename) if len(DLL_filenames) > 1: import warnings warnings.warn("loaded more than 1 DLL from .libs:\n%s" % "\n".join(DLL_filenames), stacklevel=1)
# disables OpenBLAS affinity setting of the main thread that limits # python threads or processes to one core
except ImportError as exc: import sys msg = """
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. Here is how to proceed: - If you're working with a numpy git repository, try `git clean -xdf` (removes all files not under version control) and rebuild numpy. - If you are simply trying to use the numpy version that you have installed: your installation is broken - please reinstall numpy. - If you have already reinstalled and that did not fix the problem, then: 1. Check that you are using the Python you expect (you're using %s), and that you have no directories in your PATH or PYTHONPATH that can interfere with the Python and numpy versions you're trying to use. 2. If (1) looks fine, you can open a new issue at https://github.com/numpy/numpy/issues. Please include details on: - how you installed Python - how you installed numpy - your operating system - whether or not you have multiple versions of Python installed - if you built from source, your compiler versions and ideally a build log
Note: this error has many possible causes, so please don't comment on an existing issue about this - open a new one instead.
Original error was: %s """ % (sys.executable, exc) raise ImportError(msg) finally:
# Check that multiarray,umath are pure python modules wrapping # _multiarray_umath and not either of the old c-extension modules hasattr(umath, '_multiarray_umath')): import sys path = sys.modules['numpy'].__path__ msg = ("Something is wrong with the numpy installation. " "While importing we detected an older version of " "numpy in {}. One method of fixing this is to repeatedly uninstall " "numpy until none is found, then reinstall this version.") raise ImportError(msg.format(path))
# do this after everything else, to minimize the chance of this misleadingly # appearing in an import-time traceback # add these for module-freeze analysis (like PyInstaller)
# Make it possible so that ufuncs can be pickled # Here are the loading and unloading functions # The name numpy.core._ufunc_reconstruct must be # available for unpickling to work. # The `fromlist` kwarg is required to ensure that `mod` points to the # inner-most module rather than the parent package when module name is # nested. This makes it possible to pickle non-toplevel ufuncs such as # scipy.special.expit for instance. mod = __import__(module, fromlist=[name]) return getattr(mod, name)
from pickle import whichmodule name = func.__name__ return _ufunc_reconstruct, (whichmodule(func, name), name)
else: import copy_reg as copyreg
# Unclutter namespace (must keep _ufunc_reconstruct for unpickling)
|