I am trying to use simpleITK inside the docker windows container. The container is built without any error. But when I run the container, I am getting the following error.
Traceback (most recent call last):
File “c:\helloworld.py”, line 1, in *
import SimpleITK as sitk*
File “C:\Python\lib\site-packages\SimpleITK_init_.py”, line 18, in *
from SimpleITK.SimpleITK import **
File “C:\Python\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.
Here is my Dockerfile
FROM python:3.9-windowsservercore COPY helloworld.py c:/helloworld.py COPY requirements.txt c:/requirements.txt RUN python -m pip install -r c:/requirements.txt CMD [ “python” ,“c:/helloworld.py”]
Here is the helloworld.py
import SimpleITK as sitk print(“Hello World !!!”) img = sitk.ReadImage(’./input/sample.mha’) print(img.GetDimension()) print(img.GetSize())
It looks like it’s not finding the SimpleITK shared library. There should be a ‘.pyd’ file in that same directory, C:\Python\lib\site-packages\SimpleITK`.
I wrote a little script to inspect my SimpleITK installation:
import os
import inspect
import SimpleITK as sitk
sitk_file = inspect.getfile(sitk)
print(sitk_file)
sitk_dir = os.path.dirname(sitk_file)
print(sitk_dir)
print(os.listdir(sitk_dir))
And here’s what the output looks like on my Window system:
thanks,
It helped. I checked the file was available under c:/Python/lib/site-packages/SimpleITK
I also installed the vc++ using the following command.
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe";
Start-Process -filepath C:\vc_redist.x64.exe -ArgumentList “/install”, “/passive”, “/norestart” -Passthru | Wait-Process; `
Remove-Item -Force vc_redist.x64.exe;