8000 BUG: circular import error with `linalg._matfuncs_sqrtm_triu` on 1.16.0rc1 · Issue #23037 · scipy/scipy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

BUG: circular import error with linalg._matfuncs_sqrtm_triu on 1.16.0rc1 #23037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jorenham opened this issue May 22, 2025 · 3 comments
Open
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.linalg
Milestone

Comments

@jorenham
Copy link
Contributor

Describe your issue.

from scipy.linalg import _matfuncs_sqrtm_triu raises an ImportError

Reproducing Code Example

>>> from scipy.linalg import _matfuncs_sqrtm_triu
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    from scipy.linalg import _matfuncs_sqrtm_triu
  File "scipy/linalg/_matfuncs_sqrtm_triu.pyx", line 2, in init scipy.linalg._matfuncs_sqrtm_triu
  File "/home/joren/.pyenv/versions/3.13.3/lib/python3.13/site-packages/scipy/linalg/_matfuncs_sqrtm.py", line 17, in <module>
    from ._matfuncs_sqrtm_triu import within_block_loop  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'within_block_loop' from partially initialized module 'scipy.linalg._matfuncs_sqrtm_triu' (most likely due to a circular import) (/home/joren/.pyenv/versions/3.13.3/lib/python3.13/site-packages/scipy/linalg/_matfuncs_sqrtm_triu.cpython-313-x86_64-linux-gnu.so)

Error message

Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    from scipy.linalg import _matfuncs_sqrtm_triu
  File "scipy/linalg/_matfuncs_sqrtm_triu.pyx", line 2, in init scipy.linalg._matfuncs_sqrtm_triu
  File "/home/joren/.pyenv/versions/3.13.3/lib/python3.13/site-packages/scipy/linalg/_matfuncs_sqrtm.py", line 17, in <module>
    from ._matfuncs_sqrtm_triu import within_block_loop  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'within_block_loop' from partially initialized module 'scipy.linalg._matfuncs_sqrtm_triu' (most likely due to a circular import) (/home/joren/.pyenv/versions/3.13.3/lib/python3.13/site-packages/scipy/linalg/_matfuncs_sqrtm_triu.cpython-313-x86_64-linux-gnu.so)

SciPy/NumPy/Python version and system information

>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()
1.16.0rc1 2.2.6 sys.version_info(major=3, minor=13, micro=3, releaselevel='final', serial=0)
/home/joren/.pyenv/versions/3.13.3/lib/python3.13/site-packages/scipy/__config__.py:154: UserWarning: Install `pyyaml` for better output
  warnings.warn("Install `pyyaml` for better output", stacklevel=1)
{
  "Compilers": {
    "c": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "10.2.1",
      "commands": "cc"
    },
    "cython": {
      "name": "cython",
      "linker": "cython",
      "version": "3.1.1",
      "commands": "cython"
    },
    "c++": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "10.2.1",
      "commands": "c++"
    },
    "fortran": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "10.2.1",
      "commands": "gfortran"
    },
    "pythran": {
      "version": "0.17.0",
      "include directory": "../../tmp/pip-build-env-81uwjfeo/overlay/lib/python3.13/site-packages/pythran"
    }
  },
  "Machine Information": {
    "host": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "build": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "cross-compiled": false
  },
  "Build Dependencies": {
    "blas": {
      "name": "scipy-openblas",
      "found": true,
      "version": "0.3.28",
      "detection method": "pkgconfig",
      "include directory": "/opt/_internal/cpython-3.13.2/lib/python3.13/site-packages/scipy_openblas32/include",
      "lib directory": "/opt/_internal/cpython-3.13.2/lib/python3.13/site-packages/scipy_openblas32/lib",
      "openblas configuration": "OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64",
      "pc file directory": "/project"
    },
    "lapack": {
      "name": "scipy-openblas",
      "found": true,
      "version": "0.3.28",
      "detection method": "pkgconfig",
      "include directory": "/opt/_internal/cpython-3.13.2/lib/python3.13/site-packages/scipy_openblas32/include",
      "lib directory": "/opt/_internal/cpython-3.13.2/lib/python3.13/site-packages/scipy_openblas32/lib",
      "openblas configuration": "OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64",
      "pc file directory": "/project"
    },
    "pybind11": {
      "name": "pybind11",
      "version": "2.13.6",
      "detection method": "config-tool",
      "include directory": "unknown"
    }
  },
  "Python Information": {
    "path": "/opt/python/cp313-cp313/bin/python",
    "version": "3.13"
  }
}
@jorenham jorenham added the defect A clear bug or issue that prevents SciPy from being installed or used as expected label May 22, 2025
@j-bowhay j-bowhay added this to the 1.16.0 milestone May 22, 2025
@ilayn
Copy link
Member
ilayn commented May 22, 2025

This is known and will go away once we rewrite logm. Here is a similar comment inside logm

# Avoid circular import ... this is OK, right?
import scipy.linalg._matfuncs_inv_ssq

The reason why sqrtm rewrite still left this piece in is because internally logm is still using this piece written in Cython/Pythran.

@jorenham
Copy link
Contributor Author
jorenham commented May 22, 2025

This is known and will go away once we rewrite logm

will that rewrite be included in 1.16.0?

@ilayn
Copy link
Member
ilayn commented May 22, 2025

No 1.17 earliest I think

@lucascolley lucascolley modified the milestones: 1.16.0, 1.17.0 May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.linalg
Projects
None yet
Development

No branches or pull requests

4 participants
0