Search code examples
pythonjupyter-notebookscipyanaconda

Cannot upload pickle object containing list of sparse matrices. I get ModuleNotFoundError: No module named 'scipy.sparse._arrays'


import pickle

from scipy.sparse import csr_matrix

When I try to open Pickle file containing a list of sparsematrices that I have used numerous times before without any issue, I get the following error:

ModuleNotFoundError: No module named 'scipy.sparse._arrays'

I haven't been able to find this exact error anywhere online.

I am using Jupyter notebook via Anaconda on Windows.

This problem happens with both 1.12.0 and 1.13.0 (latest) versions of Scipy package.

I have uninstalled and installed the package multiples times, but still the issue persists.


Solution

  • Ok so, OP here. I posted this on SciPy library main repository on Github and the folks there resolved this issue. Please go here.

    The problem was—as one person commented here—that the pickle file was made in an earlier version of the library and that The module scipy.sparse._arrays was removed in 1.11.0.

    I am short on time so I simply downgraded my scipy version to 1.10.0 and voila! It worked.

    To downgrade, in anaconda prompt, do:

    pip uninstall scipy

    pip install scipy==1.10.0

    Confirm by:

    pip freeze

    In the list generated, look for scipy. Next to it, its version would be written.