QSIPrep: cannot import name 'bmat' from 'scipy.sparse.sputils'

Summary of what happened:

Hi,

I am tring to run qsiprep with Singularity. But I kpet meetting this python error weather which qsiprep version I use.

Thanks in advance!

Command used (and if a helper script was used, a link to the helper script or the command generated):

singularity run --containall \
    -B /path/input:/data:ro \
    -B /path/output:/out \
    -B /path/freesurfer/license.txt:/opt/freesurfer/license.txt:ro \
    qsiprep-0.19.0.sif \
    /data /out participant \
    --participant-label 001 \
    --hmc_model 3dSHORE \
    --output-resolution 2 \
    --fs-license-file /opt/freesurfer/license.txt

Version:

0.19.0

Environment (Docker, Singularity / Apptainer, custom installation):

Singularity

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

ImportError: cannot import name 'bmat' from 'scipy.sparse.sputils' (/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/sputils.py)

I checked in the container:


(base):~$ singularity shell qsiprep-0.19.0.sif
Singularity: Invoking an interactive shell within container...

Singularity qsiprep-0.19.0.sif:/path> python
Python 3.8.10 (default, Jun  4 2021, 15:09:15) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.sprse import bmat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy.sprse'
>>> from scipy.sparse import bmat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/__init__.py", line 283, in <module>
    from . import csgraph
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/csgraph/__init__.py", line 185, in <module>
    from ._laplacian import laplacian
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/csgraph/_laplacian.py", line 7, in <module>
    from scipy.sparse.linalg import LinearOperator
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/linalg/__init__.py", line 130, in <module>
    from . import isolve, dsolve, interface, eigen, matfuncs
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/__init__.py", line 11, in <module>
    from .arpack import *
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/arpack/__init__.py", line 22, in <module>
    from .arpack import *
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py", line 53, in <module>
    from scipy.sparse.linalg.eigen.lobpcg import lobpcg
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/lobpcg/__init__.py", line 12, in <module>
    from .lobpcg import *
  File "/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py", line 25, in <module>
    from scipy.sparse.sputils import bmat
ImportError: cannot import name 'bmat' from 'scipy.sparse.sputils' (/usr/local/miniconda/lib/python3.8/site-packages/scipy/sparse/sputils.py)

Screenshots / relevant information:


Hi @ruoxi,

In the future, please use the template provided by the Software Support category. You can see I added it back in for you here.

Does this error persist in 0.20.0, the most recent version at this time? Also, you should add -e to your singularity run arguments to make sure nothing from your environment is carried over into the container.

Best,
Steven