Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import itk after installing itkwidgets #636

Open
ObliviousMonkey opened this issue Mar 20, 2023 · 0 comments
Open

Cannot import itk after installing itkwidgets #636

ObliviousMonkey opened this issue Mar 20, 2023 · 0 comments

Comments

@ObliviousMonkey
Copy link

Hi,

I'm having an issue with itk 5.3.0 which prevents me from using itkwidgets (it fails at import), as there is a check in place which fails because itk attribute __version__ does not exist:

$ import itkwidgets

...

File /opt/homebrew/Caskroom/miniconda/base/envs/ai_med/lib/python3.9/site-packages/itkwidgets/integrations/itk.py:8
      6     import itk
      7     if not hasattr(itk, '__version__') or version.parse(itk.__version__) < version.parse('5.3.0'):
----> 8       raise RuntimeError('itk 5.3 or newer is required. `pip install itk>=5.3.0`')
      9     HAVE_ITK = True
     10 except ImportError:

RuntimeError: itk 5.3 or newer is required. `pip install itk>=5.3.0`

Upon investigating, this looks like an itkwidgets issue that seems to break itk.__version__ attribute upon installation.

I'm on macOS 13.2.1 (M1), and thus cannot install itk or itkwidgets through conda.

Reproducible environment:

$ conda create --name itk python=3.9
$ pip install itk   # installs 5.3.0

Successfully installed itk-5.3.0 itk-core-5.3.0 itk-filtering-5.3.0 itk-io-5.3.0 itk-numerics-5.3.0
itk-registration-5.3.0 itk-segmentation-5.3.0 numpy-1.24.2

Let's try at this point in the terminal:

$ python
Python 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:38:11)
[Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import itk
>>> itk.__version__
'5.3.0'

Now let's install itkwidgets (here version 0.32.6):

$ pip install itkwidgets
...
Successfully installed Send2Trash-1.8.0 appnope-0.1.3 argon2-cffi-21.3.0 
argon2-cffi-bindings-21.2.0 asttokens-2.2.1 attrs-22.2.0 backcall-0.2.0 
beautifulsoup4-4.12.0 bleach-6.0.0 cffi-1.15.1 colorcet-3.0.1 comm-0.1.2 
contourpy-1.0.7 cycler-0.11.0 debugpy-1.6.6 decorator-5.1.1 defusedxml-0.7.1 
executing-1.2.0 fastjsonschema-2.16.3 fonttools-4.39.2 importlib-metadata-6.1.0 
importlib-resources-5.12.0 ipydatawidgets-4.3.2 ipykernel-6.22.0 ipympl-0.9.3 
ipython-8.11.0 ipython-genutils-0.2.0 ipywidgets-7.7.3 itk-meshtopolydata-0.10.0 
itkwidgets-0.32.6 jedi-0.18.2 jinja2-3.1.2 jsonschema-4.17.3 jupyter-client-8.1.0 
jupyter-core-5.3.0 jupyterlab-pygments-0.2.2 jupyterlab-widgets-1.1.2 
kiwisolver-1.4.4 markupsafe-2.1.2 matplotlib-3.7.1 matplotlib-inline-0.1.6 
mistune-2.0.5 nbclient-0.7.2 nbconvert-7.2.10 nbformat-5.8.0 nest-asyncio-1.5.6 
notebook-6.4.12 packaging-23.0 pandocfilters-1.5.0 param-1.13.0 parso-0.8.3 
pexpect-4.8.0 pickleshare-0.7.5 pillow-9.4.0 platformdirs-3.1.1 prometheus-client-0.16.0 
prompt-toolkit-3.0.38 psutil-5.9.4 ptyprocess-0.7.0 pure-eval-0.2.2 pycparser-2.21 
pyct-0.5.0 pygments-2.14.0 pyparsing-3.0.9 pyrsistent-0.19.3 python-dateutil-2.8.2 
pyzmq-25.0.2 six-1.16.0 soupsieve-2.4 stack-data-0.6.2 terminado-0.17.1 
tinycss2-1.2.1 tornado-6.2 traitlets-5.6.0 traittypes-0.2.1 wcwidth-0.2.6 
webencodings-0.5.1 widgetsnbextension-3.6.2 zipp-3.15.0 zstandard-0.20.0

And check again in the Python interpreter:

$ python
Python 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:38:11)
[Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import itk
>>> itk.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'itk' has no attribute '__version__'

Uninstalling itkwidgets through pip uninstall itkwidgets does not solve this at this point.

I've tried installing itkwidgets versions 0.32.6, 0.32.5, 0.32.4 with same results., as well as latest 1.0a24.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant