Installation problem of astropy via pip3

I tried to install astropy via pip3.
My environment is as follows:

  • MacBook Pro 14 inch
  • Apple M1 Max
  • macOS Monterey 12.6.1
  • Python3.10.8

When I typed “pip3 install astropy”, installation of pyerfa failed.
Though an installed version of pyerfa (0.0.0?) seems too old, I don’t know how to fix it.
I’m happy if anyone gives me feedback.

Using cached astropy-4.2.tar.gz (7.5 MB)
Installing build dependencies … error
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [75 lines of output]
Collecting setuptools
Using cached setuptools-65.6.3-py3-none-any.whl (1.2 MB)
Collecting setuptools_scm
Using cached setuptools_scm-7.0.5-py3-none-any.whl (42 kB)
Collecting wheel
Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
Collecting cython==0.29.14
Using cached Cython-0.29.14.tar.gz (2.1 MB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status ‘error’
error: subprocess-exited-with-error

pip seems to have trouble handling pyerfa’s and astropy’s dependencies on setuptools_scm – if you first run pip3 install setuptools_scm, then the version numbers should be correctly resolved.
HTH

After uninstalling all libraries installed using pip3 and reinstalling setuptools_scm first, I was able to install pyerfa and astropy.
Thank you very much!

I am trying to install astropy on windows and get same error installing the setuptools_scm does not seem to have solved. I am using Python 3.15

assuming you are installing astropy/pyerfa from local clones of the git repositories, you need to make sure you have copies of recent git tags synced locally. If you don’t, setuptools_scm will generate a default version number of 0.0.0, causing pip to fail env resolution.
This is how you do it, e.g., for astropy

git remote add upstream https://github.com/astropy/astropy
git fetch upstream --tags