How to install ITK python wheels with Slicer 4.10 and Slicer 4.11?

Hello,

I have two questions related to itk installation:

  1. I want to install itk at 4.10 Slicer version but gives me error:
    Command “python setup.py egg_info” failed with error code 1 in c:\users\siael\appdata\local\temp\pip-install-law80k\itk\

from pip._internal import main as pipmain
pipmain([“install”, “itk”])

  1. Is it possible to install a 4.XX version of itk for 4.11 version of Slicer?

Thanks

Since Slicer 4.10.2 is built against python 2.7, and there no ITK wheels for python 2.7 for latest version of ITK you would have to do this:

from pip._internal import main as pipmain
pipmain(["install", "--no-cache-dir", "itk==4.13.2"])

You could try approach described above.

Out of curiosity, is there something that should be fixed in ITK 5.x ? What motivate the use of an older ITK version ?

Hi @jcfr,
Thanks for the information.

No, there is nothing wrong that I have noticed so far.
I was wondering if I have a .exe file that I want to execute it through Slicer with different targeting vtk version (8.1.0 instead of 8.2.0), would that be an issue or the versions (itk/vtk) should much always?

Thanks

That should be no problem at all. On Windows, you just need to make sure that if that exe uses VTK or ITK DLLs then those DLLs are in the same folder as the exe file and that the folder is not added to Slicer’s module paths. Rules might be slightly different on Linux and Mac.

If by term Slicer’s module path you mean the “Additional module path” under Application Settings, then no. Thanks Andras!

Yes, I meant standard module paths (within Slicer install folder) and any additional module paths that you specify in application settings.

1 Like

Hello again,

I am trying to install itk 4.13.0 version on Slicer 4.11 (2020-06-24) but I get the following error:

from pip.internal import main as pipmain
pipmain([“install”, “–no-cache-dir”, “itk==4.13.0”])
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with ‘-m pip’ instead of running pip directly.
Traceback (most recent call last):
File “”, line 1, in
File "C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal_init
.py", line 17, in main
return wrapper(args)
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\utils\entrypoints.py”, line 31, in wrapper
return main(args)
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\cli\main.py”, line 73, in main
command = create_command(cmd_name, isolated=("–isolated" in cmd_args))
File "C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\commands_init
.py", line 104, in create_command
module = importlib.import_module(module_path)
File "C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\commands\install.py”, line 24, in
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\cli\req_command.py”, line 16, in
from pip._internal.index.package_finder import PackageFinder
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\index\package_finder.py”, line 21, in
from pip._internal.index.collector import parse_links
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\index\collector.py”, line 25, in
from pip.internal.vcs import is_url, vcs
File "C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\vcs_init
.py", line 9, in
import pip._internal.vcs.subversion # noqa: F401
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\vcs\subversion.py”, line 334, in
vcs.register(Subversion)
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\vcs\versioncontrol.py”, line 221, in register
self._registry[cls.name] = cls()
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\vcs\subversion.py”, line 192, in init
use_interactive = is_console_interactive()
File “C:\ProgramData\NA-MIC\Slicer 4.11.0-2020-06-24\lib\Python\Lib\site-packages\pip_internal\utils\misc.py”, line 875, in is_console_interactive
return sys.stdin is not None and sys.stdin.isatty()
AttributeError: ‘PythonQtStdInRedirect’ object has no attribute ‘isatty’

Do you have any idea?

Thanks

I don’t know how exactly ITK Python package is created, but since ITK is already bundled with Slicer, if you install a different version in side Slicer’s environment then there could be version conflicts. You have several options:

  • don’t use old ITK, simply use current version: pip_install('itk')
  • install old ITK in a different Python virtual environment, not in Slicer’s
  • use SimpleITK bundled with Slicer
1 Like