After switching to python 3.10 I can no longer pip install the same versions of itk as when using python 3.9.

I’m not entirely sure if this is the expected behavior or not. I have tried to find the root cause of this, but I lack the knowledge of how the internals work and I’m not able to find the cause. As far as I can see https://pypi.org/project/itk/#history lists all the versions and do not mention anything regarding python versions.

Currently I am using the latest itk version for python 3.9: 5.2.1.post1, when switching to python 3.10 the latest version is 5.0.1.

I have tested this using both my popos/ubuntu 22.04 installed python 3.10 version and using a conda environment as described below, both returns the same list of available versions.

conda create -n py310 python=3.10
conda activate py310
pip install itk==5.2.1.post1

ERROR: Could not find a version that satisfies the requirement itk==5.2.1.post1 (from versions: 4.12.0.post1, 4.13.0, 4.13.1.post1, 5.0a1, 5.0a2, 5.0b1, 5.0b3, 5.0rc1, 5.0rc2, 5.0.0, 5.0.0.post1, 5.0.1, 5.3rc2, 5.3rc2.post1, 5.3rc3, 5.3rc4, 5.3rc4.post1, 5.3rc4.post2, 5.3rc4.post3)
ERROR: No matching distribution found for itk==5.2.1.post1

Listing version for a python 3.9 environment:

conda create -n py39 python=3.9
conda activate py39
pip install itk==

ERROR: Could not find a version that satisfies the requirement itk== (from versions: 4.12.0.post1, 4.13.0, 4.13.1.post1, 5.0a1, 5.0a2, 5.0b1, 5.0b3, 5.0rc1, 5.0rc2, 5.0.0, 5.0.0.post1, 5.0.1, 5.1.1.post1, 5.1.2, 5.2rc1, 5.2rc2, 5.2rc3, 5.2.0, 5.2.0.post1, 5.2.0.post2, 5.2.0.post3, 5.2.1, 5.2.1.post1, 5.3rc1, 5.3rc2, 5.3rc2.post1, 5.3rc3, 5.3rc4, 5.3rc4.post1, 5.3rc4.post2, 5.3rc4.post3)
ERROR: No matching distribution found for itk==

the following versions are missing from the pip output when using python 3.10:

5.1.1.post1, 5.1.2, 5.2rc1, 5.2rc2, 5.2rc3, 5.2.0, 5.2.0.post1, 5.2.0.post2, 5.2.0.post3, 5.2.1, 5.2.1.post1

any suggestions as to why this is happening and/or what the cause could be would be greatly appreciated.

When looking at detailed list of files for e.g. 5.2.1, it is clear it does not have Python 3.10 wheels. 5.3rc2 is the first one which does.

Have you tried installing ITK 5.0.1 in Python 3.10?

This whole thing looks like a bug in pip.

5.0.1 has wheels for 3.8, but not 3.9. I don’t expect it would work with either of 3.9 or 3.10.

@dzenanz thank you for your reply.

I have tried installing 5.0.1 for both python 3.9 and 3.10 as suggested, which results in the following:

for my conda python 3.9 environment:

pip install itk==5.0.1
Collecting itk==5.0.1
  Using cached itk-5.0.1.tar.gz (13 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/cpvc/miniconda3/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gqv0s7fd/itk_87a7b093ae02454e9617863c6263fd62/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gqv0s7fd/itk_87a7b093ae02454e9617863c6263fd62/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-qa6u1jay
         cwd: /tmp/pip-install-gqv0s7fd/itk_87a7b093ae02454e9617863c6263fd62/
    Complete output (4 lines):
    scikit-build is required to build from source.
    Please run:
    
      python -m pip install scikit-build
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/b6/73/77f22a4ce19284e687669424dcfa5f8712bccff7c4521d38fbd6025aef21/itk-5.0.1.tar.gz#sha256=e1899170ba5d926033306ab7659169f882dd807c65a85dc0574fa775a3d643e9 (from https://pypi.org/simple/itk/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement itk==5.0.1 (from versions: 4.12.0.post1, 4.13.0, 4.13.1.post1, 5.0a1, 5.0a2, 5.0b1, 5.0b3, 5.0rc1, 5.0rc2, 5.0.0, 5.0.0.post1, 5.0.1, 5.1.1.post1, 5.1.2, 5.2rc1, 5.2rc2, 5.2rc3, 5.2.0, 5.2.0.post1, 5.2.0.post2, 5.2.0.post3, 5.2.1, 5.2.1.post1, 5.3rc1, 5.3rc2, 5.3rc2.post1, 5.3rc3, 5.3rc4, 5.3rc4.post1, 5.3rc4.post2, 5.3rc4.post3)
ERROR: No matching distribution found for itk==5.0.1

for my OS python 3.10 environment:

/usr/bin/pip install itk==5.0.1
Defaulting to user installation because normal site-packages is not writeable
Collecting itk==5.0.1
  Downloading itk-5.0.1.tar.gz (13 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [4 lines of output]
      scikit-build is required to build from source.
      Please run:
      
        python -m pip install scikit-build
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have also tried to first install the scikit-build package as suggested in the error message and then install itk==5.0.1, this however instead results in compiler errors. And as I expected itk to be installed precompiled from a wheel package this seems to confirm that 5.0.1 is not precompiled as a wheel for python 3.9 and 3.10

Going through the files in https://pypi.org/project/itk/5.0.1/#files as you suggest, clearly shows cp38 and cp39 are missing, and likewise cp310 is missing for https://pypi.org/project/itk/5.2.1/#files This must be an oversight or a bug somewhere. I however do not know the process or who is responsible for creating and maintaining these whl files. I can see that https://pypi.org/project/itk/ lists the 3 maintainers: fbudin69500 (Francois Budin), jcfr, and thewtex (Matthew McCormick) but it is unclear who to contact and how. Would the best be to open an issue on https://github.com/InsightSoftwareConsortium/ITK/issues about this?

I also found https://github.com/InsightSoftwareConsortium/ITK/issues/3587 on the issue tracker which relates to this problem.

This is not a bug, but a conscious limitation. We do not retroactively add support for new python versions to old ITK releases. All stable releases were built without Python 3.10 support. The first stable release with 3.10 support will be ITK 5.3. It is still not released. In fact, that version might come with 3.11 support too, as it is currently being worked on (e.g. ITKPythonPackage PR 218).

5.3rc2 and later have 5.10 support.

I know that situation is not ideal, but we have limited resources.

@dzenanz thank you for your answer and explaination. I am glad that you could clarify this. I will hold on to python 3.9 version, and wait until the stable ITK 5.3 version is released.

Keep up your good work, and thank you :slight_smile:

1 Like