astropy: Latest Anaconda python incompatible with astropy 5.1 & 5.2 (WCSAxes.__init__() got multiple values for argument 'wcs')
Description
I was trying to use wcs on an image following the steps in https://docs.astropy.org/en/stable/visualization/wcsaxes/index.html with astropy v5.1 and anaconda/python v 3.10 but I got an error:
WCSAxes.__init__() got multiple values for argument 'wcs'
I tried updating astropy to the latest version (5.2) with ‘conda update astropy’ but this had catastrophic effects of disappearing ipython and jupyter-notebook as well as other “jupyter-” executables from my anaconda3/bin/ directory (I dont understand how this is possible, but I confirmed it twice now). numpy also got corrupted, requiring me to completely uninstall anaconda and re-install it (which revived the astropy 5.1 version, but the wcs issue persists).
My older computer has python 3.7 and astropy 4.3 and the code works just fine (so I will not be updating on that machine for now) so the issue seems to be compatibility between the two.
Expected behavior
The code outlined in https://docs.astropy.org/en/stable/visualization/wcsaxes/index.html should work but instead the command
plt.subplot(projection=wcs)
results in these errors:
In [3]: plt.subplot(projection=wcs)
...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 plt.subplot(projection=wcs)
File ~/anaconda3/lib/python3.10/site-packages/matplotlib/pyplot.py:1311, in subplot(*args, **kwargs)
1308 break
1309 else:
1310 # we have exhausted the known Axes and none match, make a new one!
-> 1311 ax = fig.add_subplot(*args, **kwargs)
1313 fig.sca(ax)
1315 axes_to_delete = [other for other in fig.axes
1316 if other != ax and ax.bbox.fully_overlaps(other.bbox)]
File ~/anaconda3/lib/python3.10/site-packages/matplotlib/figure.py:743, in FigureBase.add_subplot(self, *args, **kwargs)
740 args = tuple(map(int, str(args[0])))
741 projection_class, pkw = self._process_projection_requirements(
742 *args, **kwargs)
--> 743 ax = projection_class(self, *args, **pkw)
744 key = (projection_class, pkw)
745 return self._add_axes_internal(ax, key)
TypeError: WCSAxes.__init__() got multiple values for argument 'wcs'
Versions
import platform; print(platform.platform()) import sys; print(“Python”, sys.version) import astropy; print(“astropy”, astropy.version) import numpy; print(“Numpy”, numpy.version) import erfa; print(“pyerfa”, erfa.version) import scipy; print(“Scipy”, scipy.version) import matplotlib; print(“Matplotlib”, matplotlib.version)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (10 by maintainers)
Hi Stuart,
Thanks for all of this – I was pulled away for something else but came back to this today. Slowly re-building things in what will hopefully be a more sensible structure. I’ll report back if I run into any more problems. Right now, i realize that installing miniforge3 does not include ipython or jupyter notebooks so i need to get those first before i can test anything.
On Fri, May 12, 2023 at 11:11 AM Stuart Mumford @.***> wrote:
This appears to be the same / similar to: https://github.com/sunpy/sunpy/issues/6946 which is that matplotlib 3.7.0 and astropy 5.1.0 are incompatible with one another, you need astropy 5.1.1 which has the bug fix for matplotlib 3.7.0 in it.
@eilatg What I would like to clarify is that with a completely clean anaconda installation you are getting version 5.1.0 of astropy and 3.7.0 of matplotlib and run into this error, without running any other install commands?
If that’s the case then it’s anaconda itself which is shipping an incompatible set of packages (not entirely its fault as there’s no metadata to tell them it’s broken).
Given all of that, I would think the fix which is likely to be the least disruptive and might actually work is after installing anaconda run
conda install astropy==5.1.1
, that should fix the bug without doing any other major version bumps which might cause the anaconda house of cards to come tumbling down.P.S. like @pllim I also recommend that people don’t use full-blown anaconda, install conda with miniconda or miniforge and then make conda envs.