1. Installing scikit-image#
How you should install scikit-image
depends on your needs and skills:
Simplest solution: scientific Python distribution.
If you can install Python packages and work in virtual environments:
Easy solution but with pitfalls: system package manager (yum, apt, …).
1.1. Supported platforms#
Windows 64-bit on x86 processors
macOS on x86 and M (ARM) processors
Linux 64-bit on x86 processors
While we do not officially support other platforms, you could still try building from source.
1.2. Version check#
To see whether scikit-image
is already installed or to check if an install has
worked, run the following in a Python shell or Jupyter notebook:
import skimage
print(skimage.__version__)
or, from the command line:
python -c "import skimage; print(skimage.__version__)"
(Try python3
if python
is unsuccessful.)
You’ll see the version number if scikit-image
is installed and
an error message otherwise.
1.3. Installation via pip and conda#
These install only scikit-image
and its dependencies; pip has an option to
include related packages.
1.3.1. pip#
Prerequisites to a pip install: You’re able to use your system’s command line to install packages and are using a virtual environment (any of several).
While it is possible to use pip without a virtual environment, it is not advised: virtual environments create a clean Python environment that does not interfere with any existing system installation, can be easily removed, and contain only the package versions your application needs. They help avoid a common challenge known as dependency hell.
To install the current scikit-image
you’ll need at least Python 3.6. If
your Python is older, pip will find the most recent compatible version.
# Update pip
python -m pip install -U pip
# Install scikit-image
python -m pip install -U scikit-image
To access the full selection of demo datasets, use scikit-image[data]
.
To include a selection of other scientific Python packages that expand
scikit-image
’s capabilities to include, e.g., parallel processing, you
can install the package scikit-image[optional]
:
python -m pip install -U scikit-image[optional]
Warning
Please do not use the command sudo
and pip
together as pip
may
overwrite critical system libraries which may require you to reinstall your
operating system.
1.3.2. conda#
Miniconda is a bare-essentials version of the Anaconda package; you’ll need to
install packages like scikit-image
yourself. Like Anaconda, it installs
Python and provides virtual environments.
conda-forge, a conda channel maintained with the latest
scikit-image
package
Once you have your conda environment set up, you can install scikit-image
with the command:
conda install scikit-image
1.4. System package managers#
Using a package manager (yum
, apt-get
, etc.) to install scikit-image
or other Python packages is not your best option:
You’re likely to get an older version.
You’ll probably want to make updates and add new packages outside of the package manager, leaving you with the same kind of dependency conflicts you see when using pip without a virtual environment.
There’s an added risk because operating systems use Python, so if you make system-wide Python changes (installing as root or using sudo), you can break the operating system.
1.5. Downloading all demo datasets#
Some of the data used in our examples is hosted online and is not installed
by default by the procedures explained above. Data are downloaded once, at the
first call, but this requires an internet connection. If you prefer downloading
all the demo datasets to be able to work offline, ensure that package pooch
is installed and then run this command:
python -c 'from skimage.data import download_all; download_all()'
or call download_all()
in your favourite interactive Python environment
(IPython, Jupyter notebook, …).
1.6. Additional help#
If you still have questions, reach out through
our user forum
our developer forum
our chat channel
To suggest a change in these instructions, please open an issue on GitHub.
2. Installing scikit-image for contributors#
We are assuming that you have a default Python environment already configured on
your computer and that you intend to install scikit-image
inside of it.
We also make a few more assumptions about your system:
You have a C compiler set up.
You have a C++ compiler set up.
You are running a version of Python compatible with our system as listed in our pyproject.toml.
You’ve cloned the git repository into a directory called
scikit-image
. You have set up the upstream remote to point to our repository and origin to point to your fork.
This directory contains the following files:
scikit-image
├── asv.conf.json
├── azure-pipelines.yml
├── benchmarks/
├── CITATION.bib
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.rst
├── CONTRIBUTORS.txt
├── doc/
├── INSTALL.rst
├── LICENSE.txt
├── MANIFEST.in
├── meson.build
├── meson.md
├── pyproject.toml
├── README.md
├── RELEASE.txt
├── requirements/
├── requirements.txt
├── skimage/
├── TODO.txt
└── tools/
All commands below are assumed to be running from the scikit-image
directory containing the files above.
2.1. Build environment setup#
Once you’ve cloned your fork of the scikit-image repository,
you should set up a Python development environment tailored for scikit-image.
You may choose the environment manager of your choice.
Here we provide instructions for two popular environment managers:
venv
(pip based) and conda
(Anaconda or Miniconda).
2.1.1. venv#
# Create a virtualenv named ``skimage-dev`` that lives outside of the repository.
# One common convention is to place it inside an ``envs`` directory under your home directory:
mkdir ~/envs
python -m venv ~/envs/skimage-dev
# Activate it
# (On Windows, please use ``skimage-dev\Scripts\activate``)
source ~/envs/skimage-dev/bin/activate
# Install main development and runtime dependencies
pip install -r requirements.txt
# Install build dependencies of scikit-image
pip install -r requirements/build.txt
# Build scikit-image from source
spin build
# Test your installation
spin test
# Build docs
spin docs
# Try the new version in IPython
spin ipython
2.1.2. conda#
When using conda for development, we recommend adding the conda-forge channel for the most up-to-date version of many dependencies. Some dependencies we use (for testing and documentation) are not available from the default Anaconda channel. Please follow the official conda-forge installation instructions before you get started.
# Create a conda environment named ``skimage-dev``
conda create --name skimage-dev
# Activate it
conda activate skimage-dev
# Install main development and runtime dependencies
conda install -c conda-forge --file requirements/default.txt
conda install -c conda-forge --file requirements/test.txt
conda install -c conda-forge pre-commit
# Install build dependencies of scikit-image
pip install -r requirements/build.txt
# Build scikit-image from source
spin build
# Test your installation
spin test
# Build docs
spin docs
# Try the new version
spin python
For more information about building and using the spin
package, see meson.md
.
2.2. Updating the installation#
When updating your installation, it is often necessary to recompile submodules that have changed. Do so with the following commands:
# Grab the latest source
git checkout main
git pull upstream main
# Update the installation
pip install -e . -vv
2.3. Testing#
scikit-image
has an extensive test suite that ensures correct
execution on your system. The test suite must pass before a pull
request can be merged, and tests should be added to cover any
modifications to the code base.
We use the pytest
testing framework, with tests located in the various
skimage/submodule/tests
folders.
Our testing requirements are listed below:
asv
matplotlib>=3.5
pooch>=1.6.0
pytest>=7.0
pytest-cov>=2.11.0
pytest-localserver
pytest-faulthandler
Run all tests using:
pytest skimage
Or the tests for a specific submodule:
pytest skimage/morphology
Or tests from a specific file:
pytest skimage/morphology/tests/test_gray.py
Or a single test within that file:
pytest skimage/morphology/tests/test_gray.py::test_3d_fallback_black_tophat
Use --doctest-modules
to run doctests. For example, run all tests and all
doctests using:
pytest --doctest-modules skimage
2.3.1. Warnings during testing phase#
Scikit-image tries to catch all warnings in its development builds to ensure
that crucial warnings from dependencies are not missed. This might cause
certain tests to fail if you are building scikit-image with versions of
dependencies that were not tested at the time of the release. To disable
failures on warnings, export the environment variable
SKIMAGE_TEST_STRICT_WARNINGS
with a value of 0 or False and run the
tests:
export SKIMAGE_TEST_STRICT_WARNINGS=False
pytest --pyargs skimage
2.4. Platform-specific notes#
Windows
A run-through of the compilation process for Windows is included in our setup of Azure Pipelines (a continuous integration service).
Debian and Ubuntu
Install suitable compilers:
sudo apt-get install build-essential
2.5. Full requirements list#
Build Requirements
# Also update `tools/pyproject.toml.in`, [build-system] -> requires
meson-python>=0.13
wheel
setuptools>=67
packaging>=21
ninja
Cython>=0.29.32
pythran
numpy>=1.21.1
# Developer UI
spin==0.3
build
Runtime Requirements
numpy>=1.21.1
scipy>=1.8
networkx>=2.8
pillow>=9.0.1
imageio>=2.27
tifffile>=2022.8.12
PyWavelets>=1.1.1
packaging>=21
lazy_loader>=0.2
Test Requirements
asv
matplotlib>=3.5
pooch>=1.6.0
pytest>=7.0
pytest-cov>=2.11.0
pytest-localserver
pytest-faulthandler
Documentation Requirements
sphinx>=5.0
sphinx-gallery>=0.11
numpydoc>=1.5
sphinx-copybutton
pytest-runner
matplotlib>=3.5
dask[array]>=2022.9.2
pandas>=1.5
seaborn>=0.11
pooch>=1.6
tifffile>=2022.8.12
myst-parser
ipywidgets
# Needed until https://github.com/jupyter-widgets/ipywidgets/issues/3731 is resolved
ipykernel
plotly>=5.10
kaleido
scikit-learn>=0.24.0
sphinx_design>=0.3
pydata-sphinx-theme>=0.13
Developer Requirements
pre-commit
rtoml
Data Requirements
The full selection of demo datasets is only available with the following installed:
pooch>=1.6.0
Optional Requirements
You can use scikit-image
with the basic requirements listed above, but some
functionality is only available with the following installed:
- Astropy
Provides FITS I/O capability.
- PyAMG
The
pyamg
module is used for the fastcg_mg
mode of random walker segmentation.
- Dask
The
dask
module is used to speed up certain functions.
SimpleITK
astropy>=5.0
# cloudpickle is necessary to provide the 'processes' scheduler for dask
cloudpickle>=0.2.1
dask[array]>=2021.1.0
matplotlib>=3.5
pooch>=1.6.0
pyamg
scikit-learn>=0.24.0
2.6. Help with contributor installation#
See Additional help above.