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

ImportError: cannot import name 'InsetPosition' from 'mpl_toolkits.axes_grid1.inset_locator' #5

Open
ns-rse opened this issue Dec 16, 2024 · 0 comments

Comments

@ns-rse
Copy link

ns-rse commented Dec 16, 2024

I discovered that the forthcoming matplotlib==3.10.0 which was released to PyPI 2024-12-14 results in an ImportError in Topoly.

The TopoStats test suite threw the error in a fresh virtual environment that had installed matplotlib==3.10.0

_______________________________________________________ ERROR collecting tests/test_entry_all_in_one.py _______________________________________________________
ImportError while importing test module '/home/neil/work/git/hub/AFM-SPM/TopoStats/tests/test_entry_all_in_one.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_entry_all_in_one.py:8: in <module>
    from topostats import run_modules
topostats/run_modules.py:33: in <module>
    from topostats.processing import (
topostats/processing.py:29: in <module>
    from topostats.tracing.ordered_tracing import ordered_tracing_image
topostats/tracing/ordered_tracing.py:12: in <module>
    from topoly import jones, translate_code
/home/neil/.virtualenvs/tmp-2e7e1dcac8fb344/lib/python3.11/site-packages/topoly/__init__.py:24: in <module>
    from .manipulation import read_file, data2dictionary, data2knotprot, data2matrix,\
/home/neil/.virtualenvs/tmp-2e7e1dcac8fb344/lib/python3.11/site-packages/topoly/manipulation.py:39: in <module>
    from topoly.plotting import Reader, KnotMap
/home/neil/.virtualenvs/tmp-2e7e1dcac8fb344/lib/python3.11/site-packages/topoly/plotting.py:13: in <module>
    from mpl_toolkits.axes_grid1.inset_locator import InsetPosition
E   ImportError: cannot import name 'InsetPosition' from 'mpl_toolkits.axes_grid1.inset_locator' (/home/neil/.virtualenvs/tmp-2e7e1dcac8fb344/lib/python3.11/site-packages/mpl_toolkits/axes_grid1/inset_locator.py)

It looks like inset_axes should be used instead according to the note on the API change

inset_location.InsetPosition has been removed; use inset_axes instead.

ns-rse added a commit to AFM-SPM/TopoStats that referenced this issue Dec 16, 2024
In addressing #986 I tested in a fresh virtual environment. This pulled in
[matplotlib-3.10.0](https://github.com/matplotlib/matplotlib/releases/tag/v3.10.0) which was released 2024-12-14 (two
days ago!). Our dependency on [topoly](topoly.cent.uw.edu.pl/documentation.html) doesn't work with this new version
because of the removal of `inset_location.InsetPosition` in favour of `inset_axes`.

This has been reported to the Topoly developers, see [ImportError: cannot import name 'InsetPosition' from
'mpl_toolkits.axes_grid1.inset_locator' · Issue #5 ·
ilbsm/topoly_tutorial](ilbsm/topoly_tutorial#5) and hopefully won't take long to resolve. For
now though we pin our dependency `matplotlib~=3.9.4` and all tests pass.
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