scipy: BUG: Windows Built SciPy can't import _fblas via pip install .

Describe your issue.

After building SciPy main branch, installing it systemwide via pip install . leads to broken import. This happens even building NumPy locally with the locally built OpenBLAS.

In [6]: np.show_config()
blas_armpl_info:
  NOT AVAILABLE
blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
    library_dirs = ['C:\\Users\\ilhan\\Documents\\GitHub\\numpy\\build\\openblas_info']
    libraries = ['openblas_info']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    library_dirs = ['C:\\Users\\ilhan\\Documents\\GitHub\\numpy\\build\\openblas_info']
    libraries = ['openblas_info']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
lapack_armpl_info:
  NOT AVAILABLE
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    library_dirs = ['C:\\Users\\ilhan\\Documents\\GitHub\\numpy\\build\\openblas_lapack_info']
    libraries = ['openblas_lapack_info']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
    library_dirs = ['C:\\Users\\ilhan\\Documents\\GitHub\\numpy\\build\\openblas_lapack_info']
    libraries = ['openblas_lapack_info']
    language = f77
    define_macros = [('HAVE_CBLAS', None)]
Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2,AVX512F,AVX512CD,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL
    not found =

Reproducing Code Example

C:\Users\ilhan\Documents\GitHub\scipy [main ≡]> $env:PKG_CONFIG_PATH="C:\opt\64\lib\pkgconfig\"
C:\Users\ilhan\Documents\GitHub\scipy [main ≡]> $env:CC="x86_64-w64-mingw32-gcc";$env:CXX="x86_64-w64-mingw32-g++"
C:\Users\ilhan\Documents\GitHub\scipy [main ≡]> pip install .
Processing c:\users\ilhan\documents\github\scipy
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.19.5 in c:\users\ilhan\appdata\local\programs\python\python310\lib\site-packages\numpy-1.24.0.dev0+695.g50a74fb65-py3.10-win-amd64.egg (from scipy==1.10.0.dev0) (1.24.0.dev0+695.g50a74fb65)
Building wheels for collected packages: scipy
  Building wheel for scipy (pyproject.toml) ... done
  Created wheel for scipy: filename=scipy-1.10.0.dev0-cp310-cp310-win_amd64.whl size=47000726 sha256=35808c560f2e33dafe3ced612713c8565d77b105aec693124ae4d13cde1afdb8
  Stored in directory: C:\Users\ilhan\AppData\Local\Temp\pip-ephem-wheel-cache-04ckr_zh\wheels\63\13\46\e3e2e5525b45f526ecce5f57def1f4d2068c8fc759a4aae4eb
Successfully built scipy
Installing collected packages: scipy
Successfully installed scipy-1.10.0.dev0

Error message

C:\Users\ilhan\Documents> ipython
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import scipy.linalg as la
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import scipy.linalg as la

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\linalg\__init__.py:197, in <module>
      1 """
      2 ====================================
      3 Linear algebra (:mod:`scipy.linalg`)
   (...)
    194
    195 """  # noqa: E501
--> 197 from ._misc import *
    198 from ._cythonized_array_utils import *
    199 from ._basic import *

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\linalg\_misc.py:3, in <module>
      1 import numpy as np
      2 from numpy.linalg import LinAlgError
----> 3 from .blas import get_blas_funcs
      4 from .lapack import get_lapack_funcs
      6 __all__ = ['LinAlgError', 'LinAlgWarning', 'norm']

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\scipy\linalg\blas.py:213, in <module>
    210 import numpy as _np
    211 import functools
--> 213 from scipy.linalg import _fblas
    214 try:
    215     from scipy.linalg import _cblas

ImportError: DLL load failed while importing _fblas: The specified module could not be found.

SciPy/NumPy/Python version information

main, main, ‘3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]’

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (20 by maintainers)

Most upvoted comments

For the interested here are the differences over the dependencies of OpenBLAS

Working one

C:\Users\ilhan>  dlldiag trace C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll
DLL Diagnostic Tools version 0.0.18
Copyright (c) 2019-2021 Adam Rehn

Parsing module header and identifying non delay-loaded dependencies... done.

Identifying the module's delay-loaded dependencies... done.

Parsed module details:
Module:          C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll
Type:            Dynamic-Link Library
Architecture:    x64

The module imports 14 direct dependencies:
api-ms-win-crt-conio-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-private-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
KERNEL32.dll

Performing LoadLibrary() trace for C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll...
Performing LoadLibrary() trace for api-ms-win-crt-conio-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-convert-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-environment-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-filesystem-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-heap-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-locale-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-math-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-private-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-runtime-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-stdio-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-string-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-time-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-utility-l1-1-0.dll...
Performing LoadLibrary() trace for KERNEL32.dll...
Done.

Summary of LdrLoadDll calls:
api-ms-win-crt-conio-l1-1-0.dll                                                                         Loaded successfully
api-ms-win-crt-convert-l1-1-0.dll                                                                       Loaded successfully
api-ms-win-crt-environment-l1-1-0.dll                                                                   Loaded successfully
api-ms-win-crt-filesystem-l1-1-0.dll                                                                    Loaded successfully
api-ms-win-crt-heap-l1-1-0.dll                                                                          Loaded successfully
api-ms-win-crt-locale-l1-1-0.dll                                                                        Loaded successfully
api-ms-win-crt-math-l1-1-0.dll                                                                          Loaded successfully
api-ms-win-crt-private-l1-1-0.dll                                                                       Loaded successfully
api-ms-win-crt-runtime-l1-1-0.dll                                                                       Loaded successfully
api-ms-win-crt-stdio-l1-1-0.dll                                                                         Loaded successfully
api-ms-win-crt-string-l1-1-0.dll                                                                        Loaded successfully
api-ms-win-crt-time-l1-1-0.dll                                                                          Loaded successfully
api-ms-win-crt-utility-l1-1-0.dll                                                                       Loaded successfully
C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll    Loaded successfully
KERNEL32.dll                                                                                            Loaded successfully

Summary of LdrpLoadDllInternal calls:
C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll    Loaded successfully
C:\Windows\SYSTEM32\ucrtbase.dll                                                                        Loaded successfully
KERNEL32.dll                                                                                            Loaded successfully

Summary of LdrpMinimalMapModule calls:
C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll    Mapped successfully

Summary of LdrpResolveDllName calls:
libopenblas.dll    C:\Users\ilhan\AppData\Local\Programs\Python\Python310\Lib\site-packages\scipy\.libs\libopenblas.dll

Broken one

DLL Diagnostic Tools version 0.0.18
Copyright (c) 2019-2021 Adam Rehn

Parsing module header and identifying non delay-loaded dependencies... done.

Identifying the module's delay-loaded dependencies... done.

Parsed module details:
Module:          C:\Users\ilhan\Documents\GitHub\scipy\build-install\Lib\site-packages\scipy\.libs\libopenblas.dll
Type:            Dynamic-Link Library
Architecture:    x64

The module imports 15 direct dependencies:
api-ms-win-crt-conio-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-private-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
KERNEL32.dll
libgcc_s_seh-1.dll
libgfortran-5.dll

Performing LoadLibrary() trace for C:\Users\ilhan\Documents\GitHub\scipy\build-install\Lib\site-packages\scipy\.libs\libopenblas.dll...
Performing LoadLibrary() trace for api-ms-win-crt-conio-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-convert-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-environment-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-filesystem-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-heap-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-locale-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-math-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-private-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-runtime-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-stdio-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-string-l1-1-0.dll...
Performing LoadLibrary() trace for api-ms-win-crt-time-l1-1-0.dll...
Performing LoadLibrary() trace for KERNEL32.dll...
Performing LoadLibrary() trace for libgcc_s_seh-1.dll...
Performing LoadLibrary() trace for libgfortran-5.dll...
Done.

Summary of LdrLoadDll calls:
api-ms-win-crt-conio-l1-1-0.dll                                                                      Loaded successfully
api-ms-win-crt-convert-l1-1-0.dll                                                                    Loaded successfully
api-ms-win-crt-environment-l1-1-0.dll                                                                Loaded successfully
api-ms-win-crt-filesystem-l1-1-0.dll                                                                 Loaded successfully
api-ms-win-crt-heap-l1-1-0.dll                                                                       Loaded successfully
api-ms-win-crt-locale-l1-1-0.dll                                                                     Loaded successfully
api-ms-win-crt-math-l1-1-0.dll                                                                       Loaded successfully
api-ms-win-crt-private-l1-1-0.dll                                                                    Loaded successfully
api-ms-win-crt-runtime-l1-1-0.dll                                                                    Loaded successfully
api-ms-win-crt-stdio-l1-1-0.dll                                                                      Loaded successfully
api-ms-win-crt-string-l1-1-0.dll                                                                     Loaded successfully
api-ms-win-crt-time-l1-1-0.dll                                                                       Loaded successfully
C:\Users\ilhan\Documents\GitHub\scipy\build-install\Lib\site-packages\scipy\.libs\libopenblas.dll    Loaded successfully
KERNEL32.dll                                                                                         Loaded successfully
libgcc_s_seh-1.dll                                                                                   Loaded successfully
libgfortran-5.dll                                                                                    Loaded successfully

Summary of LdrpLoadDllInternal calls:
C:\Users\ilhan\Documents\GitHub\scipy\build-install\Lib\site-packages\scipy\.libs\libopenblas.dll    Loaded successfully
C:\Windows\SYSTEM32\ucrtbase.dll                                                                     Loaded successfully
KERNEL32.dll                                                                                         Loaded successfully
libgcc_s_seh-1.dll                                                                                   Loaded successfully
libgfortran-5.dll                                                                                    Loaded successfully

Summary of LdrpMinimalMapModule calls:
C:\msys64\ucrt64\bin\libgcc_s_seh-1.dll                                                              Mapped successfully
C:\msys64\ucrt64\bin\libgfortran-5.dll                                                               Mapped successfully
C:\msys64\ucrt64\bin\libquadmath-0.dll                                                               Mapped successfully
C:\msys64\ucrt64\bin\libwinpthread-1.dll                                                             Mapped successfully
C:\Users\ilhan\Documents\GitHub\scipy\build-install\Lib\site-packages\scipy\.libs\libopenblas.dll    Mapped successfully
C:\Windows\System32\ADVAPI32.dll                                                                     Mapped successfully
C:\Windows\System32\msvcrt.dll                                                                       Mapped successfully
C:\Windows\System32\RPCRT4.dll                                                                       Mapped successfully
C:\Windows\System32\sechost.dll                                                                      Mapped successfully

Summary of LdrpResolveDllName calls:
libgcc_s_seh-1.dll     C:\msys64\ucrt64\bin\libgcc_s_seh-1.dll
libgfortran-5.dll      C:\msys64\ucrt64\bin\libgfortran-5.dll
libopenblas.dll        C:\Users\ilhan\Documents\GitHub\scipy\build-install\Lib\site-packages\scipy\.libs\libopenblas.dll
libquadmath-0.dll      C:\msys64\ucrt64\bin\libquadmath-0.dll
libwinpthread-1.dll    C:\msys64\ucrt64\bin\libwinpthread-1.dll