MNE NIRS/ NILearn Modules not available

  • MNE version: newest
  • operating system: Windows

when I try and import the nilearn package with the code provided below I get the error: ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found. I run all my scripts in jupyter note book and I have tried to !pip install nilearn and it says that it is downloaded and this worked for other modules that were not found in the mne.nirs package like h5io but it still is saying that the module cant be found. I am wondering if there is another way for me to install or a way around this like downloading/reinstalling mne nirs etc. any help would be greatly appriciated!

CODE
import nilearn
from nilearn.plotting import plot_design_matrix

ERROR
ImportError Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\numpy_core_init_.py:23, in
22 try:
—> 23 from . import multiarray
24 except ImportError as exc:

File ~\anaconda3\lib\site-packages\numpy_core\multiarray.py:10, in
9 import functools
—> 10 from . import overrides
11 from . import _multiarray_umath

File ~\anaconda3\lib\site-packages\numpy_core\overrides.py:8, in
7 from …_utils._inspect import getargspec
----> 8 from numpy._core._multiarray_umath import (
9 add_docstring, _get_implementing_args, _ArrayFunctionDispatcher)
12 ARRAY_FUNCTIONS = set()

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

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
File init.cython-30.pxd:1024, in numpy.import_array()

File ~\anaconda3\lib\site-packages\numpy_core_init_.py:49, in
26 msg = “”"
27
28 IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
(…)
47 “”" % (sys.version_info[0], sys.version_info[1], sys.executable,
48 version, exc)
—> 49 raise ImportError(msg)
50 finally:

ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.9 from “C:\Users\pkell\anaconda3\python.exe”
  • The NumPy version is: “1.21.5”

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
Input In [38], in <cell line: 2>()
1 import nilearn
----> 2 from nilearn.plotting import plot_design_matrix
3 import mne_nirs
4 from mne_nirs.channels import get_long_channels, get_short_channels, picks_pair_to_idx

File ~\anaconda3\lib\site-packages\nilearn\plotting_init_.py:65, in
58 from . import cm
59 from .find_cuts import (
60 find_cut_slices,
61 find_parcellation_cut_coords,
62 find_probabilistic_atlas_cut_coords,
63 find_xyz_cut_coords,
64 )
—> 65 from .html_connectome import view_connectome, view_markers
66 from .html_stat_map import view_img
67 from .html_surface import view_img_on_surf, view_surf

File ~\anaconda3\lib\site-packages\nilearn\plotting\html_connectome.py:11, in
7 from scipy import sparse
9 from nilearn.plotting.html_document import HTMLDocument
—> 11 from … import datasets
12 from . import cm
13 from .js_plotting_utils import (
14 add_js_lib,
15 colorscale,
(…)
19 to_color_strings,
20 )

File ~\anaconda3\lib\site-packages\nilearn\datasets_init_.py:23, in
1 “”“Helper functions to download NeuroImaging datasets.”“”
3 from .atlas import (
4 fetch_atlas_aal,
5 fetch_atlas_allen_2011,
(…)
21 fetch_coords_seitzman_2018,
22 )
—> 23 from .func import (
24 fetch_abide_pcp,
25 fetch_adhd,
26 fetch_bids_langloc_dataset,
27 fetch_development_fmri,
28 fetch_ds000030_urls,
29 fetch_fiac_first_level,
30 fetch_haxby,
31 fetch_language_localizer_demo_dataset,
32 fetch_localizer_button_task,
33 fetch_localizer_calculation_task,
34 fetch_localizer_contrasts,
35 fetch_localizer_first_level,
36 fetch_megatrawls_netmats,
37 fetch_mixed_gambles,
38 fetch_miyawaki2008,
39 fetch_openneuro_dataset,
40 fetch_openneuro_dataset_index,
41 fetch_spm_auditory,
42 fetch_spm_multimodal_fmri,
43 fetch_surf_nki_enhanced,
44 load_sample_motor_activation_image,
45 patch_openneuro_dataset,
46 select_from_index,
47 )
48 from .neurovault import (
49 fetch_neurovault,
50 fetch_neurovault_auditory_computation_task,
51 fetch_neurovault_ids,
52 fetch_neurovault_motor_task,
53 )
54 from .struct import (
55 GM_MNI152_FILE_PATH,
56 MNI152_FILE_PATH,
(…)
67 load_mni152_wm_template,
68 )

File ~\anaconda3\lib\site-packages\nilearn\datasets\func.py:18, in
16 import numpy as np
17 import pandas as pd
—> 18 from scipy.io import loadmat
20 try:
21 from scipy.io.matlab import MatReadError

File ~\anaconda3\lib\site-packages\scipy\io_init_.py:97, in
1 “”"
2 ==================================
3 Input and output (:mod:scipy.io)
(…)
94 ParseArffError
95 “”"
96 # matfile read and write
—> 97 from .matlab import loadmat, savemat, whosmat
99 # netCDF file support
100 from ._netcdf import netcdf_file, netcdf_variable

File ~\anaconda3\lib\site-packages\scipy\io\matlab_init_.py:45, in
1 “”"
2 MATLAB® file utilities (:mod:scipy.io.matlab)
3 ===============================================
(…)
42
43 “”"
44 # Matlab file read and write utilities
—> 45 from ._mio import loadmat, savemat, whosmat
46 from ._mio5 import MatlabFunction
47 from ._mio5_params import MatlabObject, MatlabOpaque, mat_struct

File ~\anaconda3\lib\site-packages\scipy\io\matlab_mio.py:9, in
6 from contextlib import contextmanager
8 from ._miobase import _get_matfile_version, docfiller
----> 9 from ._mio4 import MatFile4Reader, MatFile4Writer
10 from ._mio5 import MatFile5Reader, MatFile5Writer
12 all = [‘mat_reader_factory’, ‘loadmat’, ‘savemat’, ‘whosmat’]

File ~\anaconda3\lib\site-packages\scipy\io\matlab_mio4.py:13, in
8 import scipy.sparse
10 from ._miobase import (MatFileReader, docfiller, matdims, read_dtype,
11 convert_dtypes, arr_to_chars, arr_dtype_number)
—> 13 from ._mio_utils import squeeze_element, chars_to_strings
14 from functools import reduce
17 all = [
18 ‘MatFile4Reader’, ‘MatFile4Writer’, ‘SYS_LITTLE_ENDIAN’,
19 ‘VarHeader4’, ‘VarReader4’, ‘VarWriter4’, ‘arr_to_2d’, ‘mclass_info’,
(…)
22 ‘np_to_mtypes’, ‘order_codes’
23 ]

File _mio_utils.pyx:8, in init scipy.io.matlab._mio_utils()

File init.cython-30.pxd:1026, in numpy.import_array()

ImportError: numpy._core.multiarray failed to import

Could you post the output of mne.sys_info() please? It looks like you are using very old packages (e.g. NumPy 1.21.5 was released in December 2021). Please create a new environment with the latest packages as described here, or use our standalone installers.

1 Like