Installation

Requirements

Photutils has the following strict requirements:

Photutils also optionally depends on other packages for some features:

  • SciPy 1.7.2 or later: To power a variety of features in several modules (strongly recommended).

  • Matplotlib 3.5 or later: To power a variety of plotting features (e.g., plotting apertures).

  • scikit-image 0.19 or later: Used for deblending segmented sources.

  • scikit-learn 1.0 or later: Used in the deprecated DBSCANGroup class to create star groups.

  • GWCS 0.18 or later: Used in make_gwcs to create a simple celestial gwcs object.

  • Bottleneck: Improves the performance of sigma clipping and other functionality that may require computing statistics on arrays with NaN values.

  • tqdm: Used to display optional progress bars.

  • Rasterio: Used for converting source segments into polygon objects.

  • Shapely: Used for converting source segments into polygon objects.

Photutils depends on pytest-astropy (0.10 or later) to run the test suite.

Installing the latest released version

The latest released (stable) version of Photutils can be installed either with pip or conda.

Using pip

To install Photutils with pip, run:

pip install photutils

If you want to install Photutils along with all of its optional dependencies, you can instead do:

pip install "photutils[all]"

In most cases, this will install a pre-compiled version (called a wheel) of Photutils, but if you are using a very recent version of Python or if you are installing Photutils on a platform that is not common, Photutils will be installed from a source file. In this case you will need a C compiler (e.g., gcc or clang) to be installed for the installation to succeed (see Building from Source prerequisites).

If you get a PermissionError, this means that you do not have the required administrative access to install new packages to your Python installation. In this case you may consider using the --user option to install the package into your home directory. You can read more about how to do this in the pip documentation.

Do not install Photutils or other third-party packages using sudo unless you are fully aware of the risks.

Using conda

Photutils can be installed with conda if you have installed Anaconda or Miniconda. To install Photutils using the conda-forge Anaconda channel, run:

conda install -c conda-forge photutils

Building from Source

Prerequisites

You will need a compiler suite and the development headers for Python and Numpy in order to build Photutils from the source distribution. You do not need to install any other specific build dependencies (such as Cython) since these will be automatically installed into a temporary build environment by pip.

On Linux, using the package manager for your distribution will usually be the easiest route.

On macOS you will need the XCode command-line tools, which can be installed using:

xcode-select --install

Follow the onscreen instructions to install the command-line tools required. Note that you do not need to install the full XCode distribution (assuming you are using MacOS X 10.9 or later).

Installing the development version

Photutils is being developed on GitHub. The latest development version of the Photutils source code can be retrieved using git:

git clone https://github.com/astropy/photutils.git

Then to build and install Photutils (with all of its optional dependencies), run:

cd photutils
pip install ".[all]"

If you wish to install the package in “editable” mode, instead include the “-e” option:

pip install -e ".[all]"

Alternatively, pip can be used to retrieve, build, and install the latest development version from GitHub:

pip install "photutils[all] @ git+https://github.com/astropy/photutils.git"

Testing an installed Photutils

The easiest way to test your installed version of Photutils is running correctly is to use the photutils.test() function:

>>> import photutils
>>> photutils.test()

Note that this may not work if you start Python from within the Photutils source distribution directory.

The tests should run and report any failures, which you can report to the Photutils issue tracker.