ImportError: numpy.core.multiarray failed to import #6270
Labels
C: cache
Dealing with cache and files in it
state: needs discussion
This needs some more discussion
type: support
User Support
Environment
Description
I spent a few hours debugging
NumPy imports just fine but an installed package could not import numpy. (I don't actually know if that installed package could ever import numpy.)
Lots of discussions with this error message on the web, including the TensorFlow discussion with various approaches and limited successes indicate that other people have wrangled with this problem as well.
After ruling out a bunch of hypotheses (reboot; reinstall the pip that can't import numpy; reinstall python; reinstall numpy; uninstall alternate pyenv virtualenvs that contained other versions of numpy; create a minimal
test
virtualenv containing only numpy, pip, setuptools, wheel, and the package that can't import numpy; uninstall all other pyenv virtualenvs that contain numpy except the system's own python which is locked by System Integrity Protection), I finally fixed it with this:In other words, re-download and reinstall the calling package. (In my case, the relevant package was
stochastic-arrow==0.1.4
.)Before- & after-tests showed that this step fixed the problem in my minimal
test
virtualenv and separately in my main working virtualenv.Thinking about likely causes in common to the reported cases around the web leads to these ideas:
Hypothesis 1: A bug in pip can lead to cached packages with bad linkage to numpy.
Hypothesis 2: A bug in numpy's setup.py can lead to cached packages with bad linkage to numpy.
Expected behavior
Packages that happily import numpy.
How to Reproduce
Alas, I do not know how to get the computer back into the broken state.
Output
The text was updated successfully, but these errors were encountered: