gbouvignies/ChemEx

ImportError in ChemEx with Matplotlib 3.9

Closed this issue · 0 comments

Description:
When running ChemEx, an ImportError occurs due to the get_cmap function not being found in matplotlib.cm. This issue seems related to the use of Matplotlib 3.9.

Traceback:

Traceback (most recent call last):
  File "/Users/gbouvignies/Code/ChemEx/.venv/bin/chemex", line 5, in <module>
    from chemex.chemex import main
  File "/Users/gbouvignies/Code/ChemEx/chemex/chemex.py", line 23, in <module>
    from chemex.optimize.fitting import run_methods
  File "/Users/gbouvignies/Code/ChemEx/chemex/optimize/fitting.py", line 21, in <module>
    from chemex.optimize.gridding import run_grid
  File "/Users/gbouvignies/Code/ChemEx/chemex/optimize/gridding.py", line 12, in <module>
    from matplotlib.cm import get_cmap
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm' (/Users/gbouvignies/Code/ChemEx/.venv/lib/python3.12/site-packages/matplotlib/cm.py)

Steps to Reproduce:

  1. Install Matplotlib 3.9.
  2. Run ChemEx.
  3. Observe the ImportError in the traceback.

Expected Behavior:
ChemEx should import get_cmap from matplotlib.cm without errors.

Environment:

  • ChemEx version: 2024.5.0
  • Matplotlib version: 3.9
  • Python version: 3.12
  • OS: MacOS 14.5

Additional Context:
This issue likely stems from changes in the Matplotlib 3.9 update. Reverting to an earlier version of Matplotlib may be a temporary workaround.