我尝试从 nilearn.image
导入 resample_img
以用于重新采样一些医学图像。
import nibabel as nib
import nibabel.processing
from nilearn.image import resample_img
img = nib.load('./dicom_to_nifti.nii')
new_img = nibabel.processing.resample_to_output(img, (2, 2, 2))
new_img.to_filename('nifti_2_2_2')
但是我不断收到此错误,表示找不到 sklearn 模块?我已经通过 pip install sklearn 安装了它。我什至尝试卸载所有内容并重新安装,但出现了同样的问题。我确信要么是我做错了什么,要么是包有问题。
Traceback (most recent call last):
File "convert.py", line 9, in <module>
from nilearn.image import resample_img
_check_module_dependencies()
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\nilearn\version.py", line 111, in _check_module_dependencies
_import_module_with_version_check(
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\nilearn\version.py", line 60, in _import_module_with_version_check
module = __import__(module_name)
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\__init__.py", line 75, in <module>
from .utils._show_versions import show_versions
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\utils\_show_versions.py", line 12, in <module>
from ._openmp_helpers import _openmp_parallelism_enabled
ImportError: DLL load failed while importing _openmp_helpers: The specified module could not be found.. Module "sklearn" could not be found. See http://nilearn.github.io/introduction.html#installation for installation information.
PS C:\Users\craig\Documents\Files\westmead_radiomics> python test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
from nilearn.image import resample_img
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\nilearn\__init__.py", line 72, in <module>
_check_module_dependencies()
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\nilearn\version.py", line 111, in _check_module_dependencies
_import_module_with_version_check(
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\nilearn\version.py", line 60, in _import_module_with_version_check
module = __import__(module_name)
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\__init__.py", line 75, in <module>
from .utils._show_versions import show_versions
File "C:\Users\craig\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\utils\_show_versions.py", line 12, in <module>
from ._openmp_helpers import _openmp_parallelism_enabled
ImportError: DLL load failed while importing _openmp_helpers: The specified module could not be found.. Module "sklearn" could not be found. See http://nilearn.github.io/introduction.html#installation for installation information.
有什么想法吗?
最佳答案
我遇到了同样的问题并遵循了However, import sklearn still gives me error. More details are given below. How do i resolve this?的建议。
安装“Microsoft Visual C++ Redistributable for Visual Studio 2019”并重新启动后,sklearn 0.22 工作正常。
> python -c "import sklearn; sklearn.show_versions()"
System:
python: 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
executable: python.exe
machine: Windows-10-10.0.14393-SP0
Python dependencies:
pip: 19.3.1
setuptools: 40.8.0
sklearn: 0.22
numpy: 1.18.0
scipy: 1.4.1
Cython: None
pandas: 0.25.3
matplotlib: 3.1.2
joblib: 0.14.1
Built with OpenMP: True
关于python - "ImportError: DLL load failed while importing _openmp_helpers"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59206390/