Scientific-grade astronomy routines for Python
C Jupyter Notebook Python Makefile PowerShell Batchfile
Failed to load latest commit information.
appveyor Add Appveyor support files for Windows builds Sep 7, 2015
bin Rebuilt the city() geographic database using Google Maps to correct o… Dec 1, 2010
data Rebuilt the city() geographic database using Google Maps to correct o… Dec 1, 2010
ephem Fix an encoding problem with doctests Nov 9, 2016
extensions Define correct preprocessor symbol in dtoa.c according to byte order (#… Aug 12, 2016
generate Renamed ".long" to ".lon" after realizing how "longitude" is syllabif… Jan 5, 2011
issues Start investigating GitHub issue #65 Nov 27, 2014
libastro-3.7.7 Remove old debug printf()'s Aug 8, 2016
.agignore Have "ag" ignore IPython Notebooks Dec 10, 2014
.gitignore Abandon old Zope habit of an extra "src" directory May 14, 2014
.travis.yml Python 3.5 is out (#96) Aug 8, 2016
COPYING Merged copyright updates from pyephem branch. Apr 29, 2009
INSTALL Merge branch 'python3' May 14, 2014
LICENSE-GPL Rewrote the PyEphem license to the LGPL, after getting permission Sep 11, 2007
LICENSE-LGPL Rewrote the PyEphem license to the LGPL, after getting permission Sep 11, 2007 Bugfix: libastro version wrong in Sep 7, 2015
Makefile Removed old Makefile rules for building documentation (now we use Sph… Jun 12, 2008
README.rst Add instructions about running the tests Sep 1, 2015
TODO Trim old items from TODO list Nov 24, 2014
appveyor.yml Remove broken Python 2.6 build from Appveyor Aug 8, 2016 Get bdist_wheel working under Windows on Appveyor Sep 7, 2015
tox.ini Make tox work against 2.7 and 3.4 for quick check May 29, 2014



PyEphem provides an ephem Python package for performing high-precision astronomy computations. The underlying numeric routines are coded in C and are the same ones that drive the popular XEphem astronomy application, whose author, Elwood Charles Downey, generously gave permission for their use in PyEphem. The name ephem is short for the word ephemeris, which is the traditional term for a table giving the position of a planet, asteroid, or comet for a series of dates.

The PyEphem web site offers documentation and also links to the project bug tracker, user support forum, and source code repository. If you have a C compiler and the pip Python installer tool on your system, then installing PyEphem should be as easy as:

pip install ephem

There are also Windows installers in the downloads section below.

The design of PyEphem emphasizes convenience and ease of use. Both celestial bodies and the observer's location on Earth are represented by Python objects, while dates and angles automatically print themselves in standard astronomical formats:

>>> import ephem
>>> mars = ephem.Mars()
>>> mars.compute('2008/1/1')
>>> print(mars.ra)
>>> print(mars.dec)

The documentation includes both a Quick Reference and a Tutorial, which are included in text files within the module itself as well as being available on the PyEphem web site.

The features provided by PyEphem include:

  • Find where a planet, comet, or asteroid is in the sky.
    • High-precision orbital routines are provdied for the Moon, Sun, planets, and the major planet moons.
    • The user can supply the orbital elements of a comet, asteroid, or Earth-orbiting satellite, and have its location computed.
    • The positions of 94 bright stars come built-in, and the user can create further fixed objects as needed for their calculations.
  • Determine where in the sky an object appears for a particular observer.
    • The user can supply the longitude, latitude, and altitude of the location from which they will be observing.
    • For convenience, a small database of longitudes and latitudes for 122 world cities is included.
    • For specified weather conditions (temperature and pressure), PyEphem will compensate for atmospheric refraction by adjusting the positions of bodies near the horizon.
  • Compute when a body will rise, transit overhead, and set from a particular location.
  • Parse and use orbital data in either the traditional XEphem file format, or the standard TLE format used for tracking Earth-orbiting satellites.
  • Determine the dates of the equinoxes and solstices.
  • Compute the dates of the various phases of the Moon.
  • Convert from the Greenwich Time (more precisely, Ephemeris Time) which PyEphem uses to the local time of the user.
  • Convert positions between the equatorial, ecliptic, and galactic coordinate systems.
  • Determine on which page of the Uranometria or the Millennium Star Atlas a particular star should appear.
  • Return the Julian Date corresponding to any calendar date.


If you are interested in learning about how PyEphem works or in exploring its source code, check out this repository from GitHub. It is hosted at:

If you lack expertise with version control, you can instead simply download a static copy of the most recent source code using this link:

To run its source code in place, create a virtual environment, activate it, change directory to the root of the PyEphem source code, and run:

python build_ext -i

You can then run the PyEphem test suite to see whether all of its features are working correctly on your operating system and platform:

python -m unittest discover ephem