Installation

This is intended for setting up pysweph in fresh virtual environments as it cannot be installed system-wide. If you are replacing pyswisseph in an existing project or virtual environment, refer to the Migration Guide.

System requirements (C build tools)

pysweph is a Python wrapper for a C library and requires a C compiler and development headers to be installed on your system.

OS

Command

Linux (Debian/Ubuntu)

sudo apt-get install build-essential pkg-config

Linux (Fedora/RHEL)

sudo dnf install @development-tools

macOS

Install XCode Command Line Tools (xcode-select --install)

Windows

Install Build Tools for Visual Studio (with the “Desktop development with C++” workload)

PyPI installation

pyswpeh is published to PyPI.

If you’re adding pysweph to a project:

uv add pysweph

Or installing in a virtual environment:

uv venv
source .venv/bin/activate   # On Windows: .venv\Scripts\activate
uv pip install pysweph

Using pip

python3 -m venv .venv
source .venv/bin/activate   # On Windows: .venv\Scripts\Activate
pip install pysweph

Verify installation

import swisseph as swe
print(swe.version)

It should print 2.10.03.

Configuration

To go beyond the bundled data range (e.g., 13000 BCE - 4000 CE) or use extended data (e.g., asteroids), you must download the official Swiss Ephemeris .se1, .se2, etc., data files and point the library to them.

  1. Download the desired ephemerides from aloistr/swisseph.

  2. Set the path in your Python code before any calculation:

import swisseph as swe
swe.set_ephe_path("/path/to/your/ephemeris/data")