PyERFA provides Python bindings for the ERFA library (Essential Routines for Fundamental Astronomy), a C library based on the IAU SOFA library. It wraps ERFA's C routines as NumPy universal functions, allowing them to be called with scalar or array inputs. The library is actively maintained, with frequent patch releases addressing compatibility, especially with NumPy versions. The current version is 2.0.1.5.
pip install pyerfaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import `erfa` and use two common functions: `jd2cal` for Julian Date to calendar conversion and `plan94` to get a planet's heliocentric position and velocity.
Upgrade `pyerfa` to its latest version, which bundles a compatible `liberfa`. If using a system `liberfa` (via `PYERFA_USE_SYSTEM_LIBERFA=1`), ensure it is `liberfa v2.0.0` or later for `pyerfa >= 2.0.0`.
Always use the latest `pyerfa` version (>=2.0.1.3) with pre-built wheels that support the specific NumPy version in your environment. If building from source, ensure you build against your target NumPy version. Consider creating isolated environments to manage dependencies.
Ensure your NumPy installation meets the minimum requirements of your `pyerfa` version. It is generally recommended to use a recent, well-supported version of NumPy.
Most users will not be affected. If you are developing extensions or advanced integrations with `pyerfa` at the C level, be aware of the limited API constraints.
Upgrade to `pyerfa v2.0.1` or later to mitigate this issue and ensure stable behavior, particularly in optimized builds.
Reinstall pyerfa to ensure it's compiled against your current NumPy version: `pip uninstall pyerfa numpy && pip install numpy pyerfa` or `conda uninstall pyerfa numpy && conda install numpy pyerfa`. If using a specific NumPy version, ensure it's compatible or recompile pyerfa against it.
Install the pyerfa package using pip: `pip install pyerfa` or using conda: `conda install -c conda-forge pyerfa`.
Ensure both astropy and pyerfa are updated and compatible by reinstalling them: `pip install --upgrade astropy pyerfa` or `conda update astropy pyerfa`. In some cases, a full reinstallation of the environment might be necessary if conflicts persist. If `pyerfa` was a dependency from a port (e.g., MacPorts), ensure the `py-pyerfa` port is correctly installed.