Failed to import SimpleITK in Python following its installation through miniconda on Win11-x64

Hi everyone,

I would like to work with SimpleITK in Python. It seems that it has been installed successfully via miniconda on my Win11-x64 system, but when I try to import it in the interactive environment of Python, I encounter the following error:

Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import SimpleITK
Traceback (most recent call last):
File “”, line 1, in
File “C:\ProgramData\miniconda3\envs\mytorch\Lib\site-packages\SimpleITK_init_.py”, line 18, in
from SimpleITK.SimpleITK import *
File “C:\ProgramData\miniconda3\envs\mytorch\Lib\site-packages\SimpleITK\SimpleITK.py”, line 13, in
from . import _SimpleITK
ImportError: DLL load failed while importing _SimpleITK: The specified module could not be found.

By the way, this is the list of packages installed in my miniconda environment:

packages in environment at C:\ProgramData\miniconda3\envs\mytorch:

Name Version Build Channel

abseil-cpp 20230802.0 h5da7b33_2
absl-py 2.1.0 pyhd8ed1ab_0 conda-forge
aiohttp 3.9.3 py311ha68e1ae_0 conda-forge
aiosignal 1.3.1 pyhd8ed1ab_0 conda-forge
attrs 23.2.0 pyh71513ae_0 conda-forge
blas 1.0 mkl
blinker 1.7.0 pyhd8ed1ab_0 conda-forge
bottleneck 1.3.7 py311hd7041d2_0
brotli-python 1.0.9 py311hd77b12b_7
bzip2 1.0.8 he774522_0
c-ares 1.26.0 hcfcfb64_0 conda-forge
ca-certificates 2024.2.2 h56e8100_0 conda-forge
cached-property 1.5.2 py_0
cachetools 5.3.2 pyhd8ed1ab_0 conda-forge
certifi 2024.2.2 py311haa95532_0
cffi 1.16.0 py311h2bbff1b_0
charset-normalizer 2.0.4 pyhd3eb1b0_0
click 8.1.7 win_pyh7428d3b_0 conda-forge
colorama 0.4.6 py311haa95532_0
contextlib2 21.6.0 py311haa95532_0
cryptography 41.0.3 py311h89fc84f_0
cuda-cccl 12.3.101 0 nvidia
cuda-cudart 12.1.105 0 nvidia
cuda-cudart-dev 12.1.105 0 nvidia
cuda-cupti 12.1.105 0 nvidia
cuda-libraries 12.1.0 0 nvidia
cuda-libraries-dev 12.1.0 0 nvidia
cuda-nvrtc 12.1.105 0 nvidia
cuda-nvrtc-dev 12.1.105 0 nvidia
cuda-nvtx 12.1.105 0 nvidia
cuda-opencl 12.3.101 0 nvidia
cuda-opencl-dev 12.3.101 0 nvidia
cuda-profiler-api 12.3.101 0 nvidia
cuda-runtime 12.1.0 0 nvidia
eigen 3.4.0 h91493d7_0 conda-forge
fftw 3.3.10 nompi_h38027f0_108 conda-forge
filelock 3.13.1 py311haa95532_0
freetype 2.12.1 ha860e81_0
frozenlist 1.4.1 py311ha68e1ae_0 conda-forge
giflib 5.2.1 h8cc25b3_3
gmpy2 2.1.2 py311h7f96b67_0
google-auth 2.28.0 pyhca7485f_0 conda-forge
google-auth-oauthlib 1.2.0 pyhd8ed1ab_0 conda-forge
grpc-cpp 1.48.2 h6772dbd_4
grpcio 1.48.2 py311h6772dbd_4
gtest 1.14.0 h91493d7_1 conda-forge
h5py 3.8.0 nompi_py311h3a26632_100 conda-forge
hdf5 1.12.2 nompi_h57737ce_101 conda-forge
icc_rt 2022.1.0 h6049295_2
idna 3.4 py311haa95532_0
importlib-metadata 7.0.1 pyha770c72_0 conda-forge
intel-openmp 2023.1.0 h59b6b97_46320
jinja2 3.1.2 py311haa95532_0
jpeg 9e h2bbff1b_1
lerc 3.0 hd77b12b_0
libaec 1.1.2 h63175ca_1 conda-forge
libboost 1.82.0 h3399ecb_2
libboost-python 1.82.0 py311h12feb9d_6 conda-forge
libcublas 12.1.0.26 0 nvidia
libcublas-dev 12.1.0.26 0 nvidia
libcufft 11.0.2.4 0 nvidia
libcufft-dev 11.0.2.4 0 nvidia
libcurand 10.3.4.101 0 nvidia
libcurand-dev 10.3.4.101 0 nvidia
libcurl 8.5.0 h86230a5_0
libcusolver 11.4.4.55 0 nvidia
libcusolver-dev 11.4.4.55 0 nvidia
libcusparse 12.0.2.55 0 nvidia
libcusparse-dev 12.0.2.55 0 nvidia
libdeflate 1.17 h2bbff1b_1
libffi 3.4.4 hd77b12b_0
libitk 5.3.0 h6e1890f_0 conda-forge
libjpeg-turbo 2.0.0 h196d8e1_0
libnpp 12.0.2.50 0 nvidia
libnpp-dev 12.0.2.50 0 nvidia
libnvjitlink 12.1.105 0 nvidia
libnvjitlink-dev 12.1.105 0 nvidia
libnvjpeg 12.1.1.14 0 nvidia
libnvjpeg-dev 12.1.1.14 0 nvidia
libpng 1.6.39 h8cc25b3_0
libprotobuf 3.20.3 h23ce68f_0
libssh2 1.10.0 he2ea4bf_2
libtiff 4.4.0 h8a3f274_2
libuv 1.44.2 h2bbff1b_0
libwebp 1.3.2 hbc33d0d_0
libwebp-base 1.3.2 h2bbff1b_0
libzlib 1.2.13 hcfcfb64_5 conda-forge
lz4-c 1.9.4 h2bbff1b_0
markdown 3.5.2 pyhd8ed1ab_0 conda-forge
markupsafe 2.1.1 py311h2bbff1b_0
medpy 0.4.0 py311h9ea8ea8_6 conda-forge
mkl 2023.1.0 h6b88ed4_46358
mkl-service 2.4.0 py311h2bbff1b_1
mkl_fft 1.3.8 py311h2bbff1b_0
mkl_random 1.2.4 py311h59b6b97_0
ml-collections 0.1.1 pyhd8ed1ab_0 conda-forge
mpc 1.1.0 h7edee0f_1
mpfr 4.0.2 h62dcd97_1
mpir 3.0.0 hec2e145_1
mpmath 1.3.0 py311haa95532_0
multidict 6.0.5 py311ha68e1ae_0 conda-forge
networkx 3.1 py311haa95532_0
numexpr 2.8.7 py311h1fcbade_0
numpy 1.26.2 py311hdab7c0b_0
numpy-base 1.26.2 py311hd01c5d8_0
oauthlib 3.2.2 pyhd8ed1ab_0 conda-forge
openjpeg 2.4.0 h4fc8c34_0
openssl 3.2.1 hcfcfb64_0 conda-forge
pandas 2.1.4 py311hf62ec03_0
pillow 10.0.1 py311h045eedc_0
pip 23.3.1 py311haa95532_0
protobuf 3.20.3 py311hd77b12b_0
pyasn1 0.5.1 pyhd8ed1ab_0 conda-forge
pyasn1-modules 0.3.0 pyhd8ed1ab_0 conda-forge
pycparser 2.21 pyhd3eb1b0_0
pyjwt 2.8.0 pyhd8ed1ab_1 conda-forge
pyopenssl 23.2.0 py311haa95532_0
pysocks 1.7.1 py311haa95532_0
python 3.11.5 he1021f5_0
python-dateutil 2.8.2 pyhd3eb1b0_0
python-tzdata 2023.3 pyhd3eb1b0_0
python_abi 3.11 2_cp311 conda-forge
pytorch 2.1.1 py3.11_cuda12.1_cudnn8_0 pytorch
pytorch-cuda 12.1 hde6ce7c_5 pytorch
pytorch-mutex 1.0 cuda pytorch
pytz 2023.3.post1 py311haa95532_0
pyu2f 0.1.5 pyhd8ed1ab_0 conda-forge
pyyaml 6.0.1 py311h2bbff1b_0
re2 2022.04.01 h0e60522_0 conda-forge
requests 2.31.0 py311haa95532_0
requests-oauthlib 1.3.1 pyhd8ed1ab_0 conda-forge
rsa 4.9 pyhd8ed1ab_0 conda-forge
scipy 1.11.4 py311hc1ccb85_0
setuptools 68.0.0 py311haa95532_0
simpleitk 2.2.1 py311h67644cf_1 conda-forge
six 1.16.0 pyhd3eb1b0_1
sqlite 3.41.2 h2bbff1b_0
sympy 1.12 py311haa95532_0
tbb 2021.8.0 h59b6b97_0
tensorboard 2.15.2 pyhd8ed1ab_0 conda-forge
tensorboard-data-server 0.7.0 py311h1ea47a8_1 conda-forge
tensorboardx 2.2 pyhd3eb1b0_0
tk 8.6.12 h2bbff1b_0
torchaudio 2.1.1 pypi_0 pypi
torchvision 0.16.1 pypi_0 pypi
tqdm 4.65.0 py311h746a85d_0
typing_extensions 4.7.1 py311haa95532_0
tzdata 2023c h04d1e81_0
ucrt 10.0.22621.0 h57928b3_0 conda-forge
urllib3 1.26.18 py311haa95532_0
vc 14.2 h21ff451_1
vc14_runtime 14.38.33130 h82b7239_18 conda-forge
vs2015_runtime 14.38.33130 hcb4865c_18 conda-forge
werkzeug 3.0.1 pyhd8ed1ab_0 conda-forge
wheel 0.41.2 py311haa95532_0
win_inet_pton 1.1.0 py311haa95532_0
xz 5.4.2 h8cc25b3_0
yaml 0.2.5 he774522_0
yarl 1.9.4 py311ha68e1ae_0 conda-forge
zipp 3.17.0 pyhd8ed1ab_0 conda-forge
zlib 1.2.13 hcfcfb64_5 conda-forge
zstd 1.5.5 hd43e919_0

I appreciate your prompt assistance to resolve this issue.

Best,

Mohammad

Please try the latest SimpleITK 2.3.1 version from Conda forge in a clean environment.

Thank you so much. I did so, and it worked in a new conda environment. So, afterward, I specified the exact 2.3.1 version in the conda install command to make it work in the original environment too.

2 Likes

I have tried doing this as well, but doing the following:

conda install -c conda-forge simpleitk

in a fresh conda environment installs simpleitk without letting me import the module for use. It is in my environment list though:

Name Version Build Channel

_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
bzip2 1.0.8 hd590300_5 conda-forge
c-ares 1.28.1 hd590300_0 conda-forge
ca-certificates 2024.2.2 hbcca054_0 conda-forge
eigen 3.4.0 h00ab1b0_0 conda-forge
expat 2.6.2 h59595ed_0 conda-forge
fftw 3.3.10 nompi_hc118613_108 conda-forge
hdf5 1.14.3 nompi_h4f84152_100 conda-forge
icu 73.2 h59595ed_0 conda-forge
keyutils 1.6.1 h166bdaf_0 conda-forge
krb5 1.21.2 h659d440_0 conda-forge
ld_impl_linux-64 2.40 h41732ed_0 conda-forge
lerc 4.0.0 h27087fc_0 conda-forge
libaec 1.1.3 h59595ed_0 conda-forge
libcurl 8.7.1 hca28451_0 conda-forge
libdeflate 1.20 hd590300_0 conda-forge
libedit 3.1.20191231 he28a2e2_2 conda-forge
libev 4.33 hd590300_2 conda-forge
libexpat 2.6.2 h59595ed_0 conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc-ng 13.2.0 h807b86a_5 conda-forge
libgfortran-ng 13.2.0 h69a702a_5 conda-forge
libgfortran5 13.2.0 ha4646dd_5 conda-forge
libgomp 13.2.0 h807b86a_5 conda-forge
libhwloc 2.9.3 default_h554bfaf_1009 conda-forge
libiconv 1.17 hd590300_2 conda-forge
libitk 5.3.0 h26001f5_8 conda-forge
libjpeg-turbo 3.0.0 hd590300_1 conda-forge
libnghttp2 1.58.0 h47da74e_1 conda-forge
libnsl 2.0.1 hd590300_0 conda-forge
libpng 1.6.43 h2797004_0 conda-forge
libsqlite 3.45.2 h2797004_0 conda-forge
libssh2 1.11.0 h0841786_0 conda-forge
libstdcxx-ng 13.2.0 h7e041cc_5 conda-forge
libtiff 4.6.0 h1dd3fc0_3 conda-forge
libuuid 2.38.1 h0b41bf4_0 conda-forge
libwebp-base 1.3.2 hd590300_1 conda-forge
libxcrypt 4.4.36 hd590300_1 conda-forge
libxml2 2.12.6 h232c23b_1 conda-forge
libzlib 1.2.13 hd590300_5 conda-forge
ncurses 6.4.20240210 h59595ed_0 conda-forge
openssl 3.2.1 hd590300_1 conda-forge
pip 24.0 pyhd8ed1ab_0 conda-forge
python 3.12.2 hab00c5b_0_cpython conda-forge
python_abi 3.12 4_cp312 conda-forge
readline 8.2 h8228510_1 conda-forge
setuptools 69.2.0 pyhd8ed1ab_0 conda-forge
simpleitk 2.3.1 py312h30efb56_2 conda-forge
tbb 2021.11.0 h00ab1b0_1 conda-forge
tk 8.6.13 noxft_h4845f30_101 conda-forge
tzdata 2024a h0c530f3_0 conda-forge
wheel 0.43.0 pyhd8ed1ab_1 conda-forge
xz 5.2.6 h166bdaf_0 conda-forge
zlib 1.2.13 hd590300_5 conda-forge
zstd 1.5.5 hfc55251_0 conda-forge

Hello,

The following Dockerfile works:

FROM ubuntu:22.04

ADD https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh /root
RUN bash /root/Miniconda3-latest-Linux-x86_64.sh -b -p /root/miniconda3
RUN . /root/miniconda3/bin/activate && \
    conda config --add channels conda-forge && \
    conda config --set channel_priority strict && \
    conda install simpleitk
RUN . /root/miniconda3/bin/activate && \
    python -c "import SimpleITK; print(SimpleITK.Version())"
ENTRYPOINT ["/root/miniconda3/bin/conda", "list"]

I am not sure what is different about your environment to cause the issue or conflict of packages. If you are able to reproduce the issue in a Dockerfile, then it can be looked into further.

1 Like