Open jrthorstensen opened 2 years ago
Tiny update -- I think everything I'm doing here is with FITSFigure, so I tried changing the import to
from aplpy import FITSFigure
and it fails in the same way.
Sure enough, I got it running by changing the import line in aplpy's "core.py" from
from astropy.nddata.utils import block_reduce
to
from astropy.nddata import block_reduce
I'm only using FITSFigure, so I haven't run any extensive tests. - John
Thanks for reporting this. This is actually the incompatibility fixed in e8c72f0 for the 2.1 release, but the conda channels might need a little more time yet to update to the newest version. In urgent cases you may already install the current release using pip install 'aplpy>=2.1.0'
.
Thanks! I forced the upgrade as you suggested and it now runs without complaining.
Just an FYI @dhomeier @astrofrog, I just did a brand new install of aplpy
via conda-forge
today and it seems 2.0.3 is still the latest version available there.
Chiming in here. I just upgraded my astropy to 5.2.2 and ran into this same conflict ImportError: cannot import name 'block_reduce' from 'astropy.nddata.utils' (/Users/ryan/anaconda3/lib/python3.9/site-packages/astropy/nddata/utils.py)
. Even after ensuring my aplpy version is 2.1.0 (via a forced upgrade), I hit the same error. I'm running Mac OS Monterey v12.4.
I attempted the quick fix provided above by @jrthorstensen above, but I then encounter a different error with a traceback:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 10
8 from astroquery.skyview import SkyView
9 import matplotlib.pyplot as plt
---> 10 import aplpy
11 import wget
12 import urllib.request
File ~/anaconda3/lib/python3.9/site-packages/aplpy/__init__.py:14
10 # ----------------------------------------------------------------------------
12 if not _ASTROPY_SETUP_: # noqa
---> 14 from .core import FITSFigure # noqa
15 from .rgb import make_rgb_image, make_rgb_cube # noqa
17 from .frame import Frame # noqa
File ~/anaconda3/lib/python3.9/site-packages/aplpy/core.py:30
27 from . import slicer
29 from .compat import simple_norm
---> 30 from .layers import Layers
31 from .grid import Grid
32 from .ticks import Ticks
File ~/anaconda3/lib/python3.9/site-packages/aplpy/layers.py:9
5 from matplotlib.contour import ContourSet
6 from matplotlib.collections import RegularPolyCollection, \
7 PatchCollection, CircleCollection, LineCollection
----> 9 from .regions import ArtistCollection
10 from .decorators import auto_refresh
13 class Layers(object):
File ~/anaconda3/lib/python3.9/site-packages/aplpy/regions.py:6
3 from astropy import log
4 from astropy import wcs
----> 6 from .decorators import auto_refresh
9 class Regions(object):
10 """
11 Regions sub-class of APLpy.
12
(...)
41
42 """
File ~/anaconda3/lib/python3.9/site-packages/aplpy/decorators.py:5
1 from __future__ import absolute_import, print_function, division
3 import threading
----> 5 from astropy.utils.decorators import wraps
7 mydata = threading.local()
9 __all__ = ['auto_refresh', 'fixdocstring']
ImportError: cannot import name 'wraps' from 'astropy.utils.decorators' (/Users/ryan/anaconda3/lib/python3.9/site-packages/astropy/utils/decorators.py)
Other than trying to roll back my astropy installation, I'm not quite sure what to do. Correction: the solution outlined by bencooper1 in open issue #474 solved this additional issue. Aplpy can now be imported.
Both these issues have been fixed in 2.1.0 (#469 and #471); you could install the latest release through pip
, but I am also only getting 2.0.3 from mambaforge. @astrofrog do you have an idea how to poke conda/condaforge to pull the current version?
Thanks for the response, @dhomeier. I ran into these issues even after installing 2.1.0 through pip, which is why I was rather confused about running into these errors.
You mean you have an installation that reports aplpy.version.version == '2.1.0'
and are still getting those errors?
So I had thought. I attempted pip install 'aplpy>=2.1.0'
, and once I checked the version number using conda list
, it appeared that I had the correct version number (2.1.0). But loading a python session, importing aplpy, and checking aplpy.version.version
returned 2.0.3 just a moment ago. Using pip install --force-reinstall aplpy
has now brought it up to the correct version number: aplpy.version.version=='2.1.0'
.
I appreciate the help and I apologize for my confusion!
Thanks for the feedback; pip installs on top of conda can create confusion over what is already installed, so it is indeed regrettable condaforge has still not been able to update its package!
Thanks, I have faced the same problem and fixed it installing via pip
. I really wish the Conda folks would bump the version in the repositories so it would be, like, not broken.
The merging of conda-forge/aplpy-feedstock#10 earlier this morning has now made APLpy v2.1.0 available through conda-forge. It seems that should likely resolve all of the issues discussed here.
I'm trying to run a python 3 script calling APLpy from a conda python 3.9 environment on Linux. It fails with:
I looked at this and it appears that block_reduce is now in astropy/nddata, not in astropy/nddata/utils:
I suppose I could try to fix my own code by taking out the blanket-import and importing just the part of aplpy I need, which might work, but in the meatime I figured the maintainers would want to know about this. -- John Thorstensen