python - “ImportError:导入 _openmp_helpers 时 DLL 加载失败”?
问题描述
我尝试导入resample_img
fromnilearn.image
以用于重新采样一些医学图像。
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.
有任何想法吗?
解决方案
我遇到了同样的问题并遵循了但是 import sklearn 的建议仍然给我错误。更多细节如下。我该如何解决这个问题?.
安装“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
推荐阅读
- c# - 捕获 TableLayoutPanel 特定区域的图像
- django - 将数据字典与模型实例解析为 Django ModelForm
- python - 使用 pandas 获取两个数据框之间的匹配值
- system-verilog - 不可综合的时钟风格:只有条件操作或 if 语句在 sync-async always 块中被支持
- c++ - GLSL:CPU 共享原子负载
- c - C 在屏幕上显示字体图像素
- airflow - 典型方式通过气流或用户调用 azure databricks 应用程序
- c++ - 如何配置 libclang 以使用 Visual Studio 2019?
- spring - Spring将对象从视图发送到控制器
- java - @Modifying 注释即使没有属性“flushautomatically=true”也会刷新持久性上下文