scipy: DLL load failure when importing after PyTorch

My issue is about DLL load failure on Windows. We are using Anaconda. It is causing test jobs to fail at PyTorch: https://github.com/pytorch/pytorch/issues/40366. Currently, we are downgrading it to 1.4.1.

Reproducing code example:

pip install --pre scipy torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
python -c "import torch; from scipy import stats"

Error message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Jenkins\Miniconda3\lib\site-packages\scipy\__init__.py", line 104, in <module>
    from . import _distributor_init
  File "C:\Jenkins\Miniconda3\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Jenkins\Miniconda3\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Scipy/Numpy/Python version information:

1.5.0 1.18.1 sys.version_info(major=3, minor=6, micro=7, releaselevel='final', serial=0)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 29 (20 by maintainers)

Most upvoted comments

The from . import __config__ could also be added to _distributor_init.py.

Also, the numpy-distutils submodule in scipy-wheels maybe needs to be bumped to recent numpy, so that the __config__.py snippet is updated, to use os.add_dll_directory on python3.8 instead of PATH manipulations.

Also, in numpy’s __init__.py, _distributor_init is imported after __config__, opposite to scipy. We probably should sync how all this works with Numpy.