Search code examples
pythoncondaastropyvirtual-environment

Can't update module astropy in an environment


I'm running Anaconda with an environment phd, and I'm trying to update astropy to the current version (5.0.4, same as in my base environment).

>>> conda activate phd
>>> python
Python 3.7.1 (default, Oct 28 2018, 08:39:03) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import astropy
>>> print(astropy.__version__)
4.3.1

In the base environment, I get

>>> python
Python 3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: Anaconda,
Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import astropy
>>> print(astropy.__version__)
5.0.4
>>>

I've tried conda upgrade astropy from within phd, and conda update --name phd astropy, both of which return

Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

Retrieving notices: ...working... done

What am I doing wrong?


Solution

  • Python 3.7 is not supported. Unless a Python package is designated as noarch - astropy is not -, a build must be made for each Python version. A maintainer of the Conda Forge astropy feedstock dropped support for Python 3.7 in Nov. 2022. This was consistent with the documented requirements of astropy, that show version 5+ requiring Python 3.8+.

    If you would like to use the newer versions of astropy then create a new environment with a more recent version of Python. I would not recommend upgrading Python in-place, since most packages will have to be replaced anyway.