Open 1fish2 opened 5 years ago
When we download source distributions (which stochastic-arrow provides), we typically build a wheel and cache and install it. For legacy builds (for projects that don't use pyproject.toml
, the build takes place in whatever the current environment is using whatever dependencies are available. If stochastic-arrow was installed in an environment with a numpy==1.X and then installed in another environment with numpy==1.Y, the latter environment would get the cached wheel and that could potentially cause issues like what you're seeing.
There are some related issues like #2882, however I can't find one that matches this exactly.
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