scipy: Query: `TypeError` when importing `interpolate`

Describe your issue.

Trying to import scipy.stats raises a TypeError.

Reproducing Code Example

import scipy.stats

Error message

Traceback (most recent call last):
  File "/Users/reeschang/PycharmProjects/InverseXRD/raw_xrd_simulation.py", line 244, in <module>
    import scipy.stats
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/stats/__init__.py", line 606, in <module>
    from ._stats_py import *
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/stats/_stats_py.py", line 49, in <module>
    from . import distributions
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/stats/distributions.py", line 11, in <module>
    from . import _discrete_distns
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/stats/_discrete_distns.py", line 10, in <module>
    from scipy.interpolate import interp1d
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/interpolate/__init__.py", line 167, in <module>
    from ._interpolate import *
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/interpolate/_interpolate.py", line 14, in <module>
    from . import _fitpack_py
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/interpolate/_fitpack_py.py", line 8, in <module>
    from ._fitpack_impl import bisplrep, bisplev, dblint  # noqa: F401
  File "/Users/reeschang/miniconda3/envs/ml4pxrds/lib/python3.9/site-packages/scipy/interpolate/_fitpack_impl.py", line 103, in <module>
    'iwrk': array([], dfitpack_int), 'u': array([], float),
TypeError

SciPy/NumPy/Python version and system information

1.13.1 1.26.4 sys.version_info(major=3, minor=9, micro=19, releaselevel='final', serial=0)
Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: /Users/reeschang/miniconda3/envs/ml4pxrds/include
    lib directory: /Users/reeschang/miniconda3/envs/ml4pxrds/lib
    name: blas
    openblas configuration: unknown
    pc file directory: /Users/reeschang/miniconda3/envs/ml4pxrds/lib/pkgconfig
    version: 3.9.0
  lapack:
    detection method: pkgconfig
    found: true
    include directory: /Users/reeschang/miniconda3/envs/ml4pxrds/include
    lib directory: /Users/reeschang/miniconda3/envs/ml4pxrds/lib
    name: lapack
    openblas configuration: unknown
    pc file directory: /Users/reeschang/miniconda3/envs/ml4pxrds/lib/pkgconfig
    version: 3.9.0
  pybind11:
    detection method: pkgconfig
    include directory: /Users/reeschang/miniconda3/envs/ml4pxrds/include
    name: pybind11
    version: 2.12.0
Compilers:
  c:
    args: -march=core2, -mtune=haswell, -mssse3, -ftree-vectorize, -fPIC, -fstack-protector-strong,
      -O2, -pipe, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include, -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/work=/usr/local/src/conda/scipy-split-1.13.1,
      -fdebug-prefix-map=/Users/reeschang/miniconda3/envs/ml4pxrds=/usr/local/src/conda-prefix,
      -D_FORTIFY_SOURCE=2, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include,
      -mmacosx-version-min=10.13, -mmacosx-version-min=10.13
    commands: x86_64-apple-darwin13.4.0-clang
    linker: ld64
    linker args: -Wl,-headerpad_max_install_names, -Wl,-dead_strip_dylibs, -Wl,-rpath,/Users/reeschang/miniconda3/envs/ml4pxrds/lib,
      -L/Users/reeschang/miniconda3/envs/ml4pxrds/lib, -march=core2, -mtune=haswell,
      -mssse3, -ftree-vectorize, -fPIC, -fstack-protector-strong, -O2, -pipe, -isystem,
      /Users/reeschang/miniconda3/envs/ml4pxrds/include, -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/work=/usr/local/src/conda/scipy-split-1.13.1,
      -fdebug-prefix-map=/Users/reeschang/miniconda3/envs/ml4pxrds=/usr/local/src/conda-prefix,
      -D_FORTIFY_SOURCE=2, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include,
      -mmacosx-version-min=10.13, -mmacosx-version-min=10.13
    name: clang
    version: 16.0.6
  c++:
    args: -march=core2, -mtune=haswell, -mssse3, -ftree-vectorize, -fPIC, -fstack-protector-strong,
      -O2, -pipe, -stdlib=libc++, -fvisibility-inlines-hidden, -fmessage-length=0,
      -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include, -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/work=/usr/local/src/conda/scipy-split-1.13.1,
      -fdebug-prefix-map=/Users/reeschang/miniconda3/envs/ml4pxrds=/usr/local/src/conda-prefix,
      -D_FORTIFY_SOURCE=2, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include,
      -mmacosx-version-min=10.13, -mmacosx-version-min=10.13
    commands: x86_64-apple-darwin13.4.0-clang++
    linker: ld64
    linker args: -Wl,-headerpad_max_install_names, -Wl,-dead_strip_dylibs, -Wl,-rpath,/Users/reeschang/miniconda3/envs/ml4pxrds/lib,
      -L/Users/reeschang/miniconda3/envs/ml4pxrds/lib, -march=core2, -mtune=haswell,
      -mssse3, -ftree-vectorize, -fPIC, -fstack-protector-strong, -O2, -pipe, -stdlib=libc++,
      -fvisibility-inlines-hidden, -fmessage-length=0, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include,
      -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/work=/usr/local/src/conda/scipy-split-1.13.1,
      -fdebug-prefix-map=/Users/reeschang/miniconda3/envs/ml4pxrds=/usr/local/src/conda-prefix,
      -D_FORTIFY_SOURCE=2, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include,
      -mmacosx-version-min=10.13, -mmacosx-version-min=10.13
    name: clang
    version: 16.0.6
  cython:
    commands: cython
    linker: cython
    name: cython
    version: 3.0.10
  fortran:
    args: -march=core2, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector,
      -O2, -pipe, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include, -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/work=/usr/local/src/conda/scipy-split-1.13.1,
      -fdebug-prefix-map=/Users/reeschang/miniconda3/envs/ml4pxrds=/usr/local/src/conda-prefix
    commands: /Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/_build_env/bin/x86_64-apple-darwin13.4.0-gfortran
    linker: ld64
    linker args: -Wl,-headerpad_max_install_names, -Wl,-dead_strip_dylibs, -Wl,-rpath,/Users/reeschang/miniconda3/envs/ml4pxrds/lib,
      -L/Users/reeschang/miniconda3/envs/ml4pxrds/lib, -march=core2, -mtune=haswell,
      -ftree-vectorize, -fPIC, -fstack-protector, -O2, -pipe, -isystem, /Users/reeschang/miniconda3/envs/ml4pxrds/include,
      -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/scipy-split_1716470285601/work=/usr/local/src/conda/scipy-split-1.13.1,
      -fdebug-prefix-map=/Users/reeschang/miniconda3/envs/ml4pxrds=/usr/local/src/conda-prefix
    name: gcc
    version: 12.3.0
  pythran:
    include directory: ../../_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.9/site-packages/pythran
    version: 0.16.0
Machine Information:
  build:
    cpu: x86_64
    endian: little
    family: x86_64
    system: darwin
  cross-compiled: false
  host:
    cpu: x86_64
    endian: little
    family: x86_64
    system: darwin
Python Information:
  path: /Users/reeschang/miniconda3/envs/ml4pxrds/bin/python
  version: '3.9'

About this issue

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

Most upvoted comments

I also encountered this error with Python 3.10 and SciPy 1.14.0. I solved it by downgrading SciPy to version 1.12.x:

pip install 'scipy<1.13.0'

update python to 3.12 and it works without error, thanks!

It looks like an installation problem more than a bug in a particular sub-package, but I’ve re-labeled the issue issue because the TypeError appears to come from interpolate.

Ah, that is scikit-learn 1.5.0, not SciPy 1.5.0.

After pip install scikit-learn==1.5.0, could you enter a Python interpreter and paste the result of import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()? Or does the error arise immediately from that?

1.13.1 1.26.4 sys.version_info(major=3, minor=9, micro=19, releaselevel='final', serial=0)
Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: /opt/arm64-builds/include
    lib directory: /opt/arm64-builds/lib
    name: openblas
    openblas configuration: USE_64BITINT=0 DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS=
      NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP= SANDYBRIDGE MAX_THREADS=64
    pc file directory: /opt/arm64-builds/lib/pkgconfig
    version: 0.3.27
  lapack:
    detection method: pkgconfig
    found: true
    include directory: /opt/arm64-builds/include
    lib directory: /opt/arm64-builds/lib
    name: openblas
    openblas configuration: USE_64BITINT=0 DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS=
      NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP= SANDYBRIDGE MAX_THREADS=64
    pc file directory: /opt/arm64-builds/lib/pkgconfig
    version: 0.3.27
  pybind11:
    detection method: config-tool
    include directory: unknown
    name: pybind11
    version: 2.12.0
Compilers:
  c:
    commands: cc
    linker: ld64
    name: clang
    version: 15.0.0
  c++:
    commands: c++
    linker: ld64
    name: clang
    version: 15.0.0
  cython:
    commands: cython
    linker: cython
    name: cython
    version: 3.0.10
  fortran:
    commands: gfortran
    linker: ld64
    name: gcc
    version: 12.1.0
  pythran:
    include directory: ../../../../../../private/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T/pip-build-env-ddcl7dz8/overlay/lib/python3.9/site-packages/pythran
    version: 0.15.0
Machine Information:
  build:
    cpu: aarch64
    endian: little
    family: aarch64
    system: darwin
  cross-compiled: false
  host:
    cpu: aarch64
    endian: little
    family: aarch64
    system: darwin
Python Information:
  path: /private/var/folders/2f/8t5k6yr535sdw0s4glnpxrzm0000gn/T/cibw-run-_36keccq/cp39-macosx_arm64/build/venv/bin/python
  version: '3.9'