ephem
Compute positions of the planets and stars
What it is and what it does
PyEphem is a Python wrapper around high-precision C-based astronomy computation routines originally from the XEphem application. It lets you compute where celestial objects appear in the sky from any location on Earth at any date, handling the complex orbital mechanics and coordinate transformations automatically. The package represents planets, moons, stars, comets, and asteroids as Python objects, and automatically formats dates and angles in standard astronomical notation.
Typical use involves creating an observer object with a location (longitude, latitude, altitude), creating or loading a celestial body (planets and major moons are built-in, or you can supply orbital elements), computing its position for a specific date, and reading off coordinates like right ascension and declination. The package also handles rise/transit/set times, Moon phases, equinoxes, solstices, coordinate system conversions, and includes a database of 122 world cities for convenience.
Use it for:
- Determine when and where to observe a planet or comet from a specific location on a given night
- Calculate the Moon's phase and position for calendar or astronomical applications
- Track Earth-orbiting satellites using TLE orbital data
- Find the dates of equinoxes, solstices, and lunar phases for a calendar year
- Convert between equatorial, ecliptic, and galactic coordinate systems for star catalogs
- Compute atmospheric refraction corrections for objects near the horizon
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyEphem computes high-precision positions of planets, moons, stars, comets, and asteroids in the sky for any observer location and date, using C-based numeric routines from the XEphem astronomy application.
Yes. PyEphem is a mature, actively maintained library with no known vulnerabilities, a permissive MIT license, and broad platform support via pre-built wheels. Install friction is moderate but manageable. It is the standard choice for Python-based high-precision astronomy calculations and is well-suited for anyone building observational astronomy, planetarium, or satellite-tracking tools.
Install
ephem on PyPI
pip
pip install ephemuv
uv add ephempoetry
poetry add ephemInstalling ephem
Before you install
Medium install friction due to C extension compilation, but pre-built wheels cover most modern Python versions and platforms. The package is actively maintained with recent commits and has been stable since its 2008 release.
License in practice
MIT license is permissive; you can use, modify, and distribute PyEphem freely in commercial or private projects with minimal restrictions.
Quickstart
pip install ephem
import ephem
mars = ephem.Mars()
mars.compute('2008/1/1')
print(mars.ra) # prints 5:59:27.35
print(mars.dec) # prints 26:56:27.4
A C compiler is required if installing from source; pre-built wheels are available for most platforms, eliminating this requirement for standard installations.
Verify before relying
- Precision level (number of decimal places or arcsecond accuracy) of position computations
- Performance characteristics for batch computations of many bodies or dates
- Whether atmospheric refraction compensation works for all observer altitudes
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 167 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,567,267/month — #3,754 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ephem-4.2.1-cp27-cp27m-manylinux2010_i686.whl; ephem-4.2.1-cp27-cp27m-manylinux2010_x86_64.whl; ephem-4.2.1-cp27-cp27mu-manylinux2010_i686.whl; ephem-4.2.1-cp27-cp27mu-manylinux2010_x86_64.whl; ephem-4.2.1-cp310-cp310-macosx_10_9_x86_64.whl; ephem-4.2.1-cp310-cp310-macosx_11_0_arm64.whl; ephem-4.2.1-cp310-cp310-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl; ephem-4.2.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; ephem-4.2.1-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl; ephem-4.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; ephem-4.2.1-cp310-cp310-musllinux_1_2_aarch64.whl; ephem-4.2.1-cp310-cp310-musllinux_1_2_i686.whl; ephem-4.2.1-cp310-cp310-musllinux_1_2_s390x.whl; ephem-4.2.1-cp310-cp310-musllinux_1_2_x86_64.whl; ephem-4.2.1-cp310-cp310-win32.whl; ephem-4.2.1-cp310-cp310-win_amd64.whl; ephem-4.2.1-cp311-cp311-macosx_10_9_x86_64.whl; ephem-4.2.1-cp311-cp311-macosx_11_0_arm64.whl; ephem-4.2.1-cp311-cp311-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl; ephem-4.2.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Tags
More Astronomy packages
Albumentations applies image transformations to…
permissive · top 5,000 on PyPI
convertdateConverts dates between the Gregorian calendar…
permissive · top 5,000 on PyPI
jdcalConverts between Julian dates and Gregorian or…
permissive · top 5,000 on PyPI
pyerfaPyERFA wraps the ERFA C library (Essential…
permissive · top 5,000 on PyPI
PyMeeusPyMeeus implements astronomical algorithms from…
copyleft · top 5,000 on PyPI
numpy-quaternionAdds a quaternion dtype to NumPy, enabling…
permissive · top 5,000 on PyPI
jplephemLoads and queries JPL ephemeris files (SPK…
permissive · top 5,000 on PyPI
skyfieldSkyfield computes high-precision positions for…
permissive · top 15,000 on PyPI
spiceypySpiceyPy wraps the NAIF C SPICE Toolkit to…
permissive · top 15,000 on PyPI
pyorbitalPyorbital computes orbital parameters from TLE…
permissive · top 15,000 on PyPI
sgp4Computes satellite positions in Earth orbit…
permissive · top 5,000 on PyPI
skyfield-dataProvides pre-packaged astronomical data files…
permissive · top 15,000 on PyPI
kerykeionKerykeion computes planetary and house…
copyleft · top 15,000 on PyPI