1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
|
.. _installing-scikit-image:
Installing scikit-image
==============================================================================
- First, you need to have the Python language installed.
Two popular routes are the pip-based
`Python.org installers <https://www.python.org/downloads/>`_
and the conda-based
`miniforge <https://github.com/conda-forge/miniforge>`_.
- Install ``scikit-image`` via `pip <#install-via-pip>`_ or `conda
<#install-via-conda>`_, as appropriate.
- Or, `build the package from source
<#installing-scikit-image-for-contributors>`_.
Do this if you'd like to contribute to development.
Supported platforms
------------------------------------------------------------------------------
- Windows 64-bit on x86 processors
- macOS on x86 and ARM (M1, etc.) processors
- Linux 64-bit on x86 and ARM processors
While we do not officially support other platforms, you could still
try `building from source <#building-from-source>`_.
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:
.. code-block:: python
import skimage as ski
print(ski.__version__)
or, from the command line:
.. code-block:: sh
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.
Installation via pip and conda
------------------------------------------------------------------------------
.. _install-via-pip:
pip
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Prerequisites to a pip install: you must be able to use ``pip`` on
your command line to install packages.
We strongly recommend the use of a
`virtual environment
<https://towardsdatascience.com/virtual-environments-104c62d48c54?gi=2532aa12906#ee81>`_.
A virtual environment creates a clean Python environment that does not interfere
with the existing system installation, can be easily removed, and contains only
the package versions your application needs.
To install the current ``scikit-image`` you'll need at least Python 3.11. If
your Python is older, pip will find the most recent compatible version.
.. code-block:: sh
# Update pip
python -m pip install -U pip
# Install scikit-image
python -m pip install -U scikit-image
Some additional dependencies are required to access all example
datasets in ``skimage.data``. Install them using:
.. code-block:: sh
python -m pip install -U scikit-image[data]
To install optional scientific Python packages that expand
``scikit-image``'s capabilities to include, e.g., parallel processing,
use:
.. code-block:: sh
python -m pip install -U scikit-image[optional]
.. warning::
Do not use the command ``sudo`` and ``pip`` together as ``pip`` may
overwrite critical system libraries.
.. _install-via-conda:
conda
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We recommend `miniforge <https://github.com/conda-forge/miniforge>`_, a minimal
distribution that makes use of `conda-forge <https://conda-forge.org>`_.
It installs Python and provides virtual environments.
Once you have your conda environment set up, install ``scikit-image`` with:
.. code-block:: sh
conda install scikit-image
System package managers
------------------------------------------------------------------------------
Using a package manager (``apt``, ``dnf``, etc.) to install ``scikit-image``
or other Python packages is not your best option, since you're likely
to get an older version. It also becomes harder to install other Python packages
not provided by the package manager.
Downloading all demo datasets
------------------------------------------------------------------------------
Some of our example images (in ``skimage.data``) are hosted online and are
not installed by default. These images are downloaded upon first
access. If you prefer to download all demo datasets, so they can be
accessed offline, ensure that ``pooch`` is installed, then run:
.. code-block:: sh
python -c 'import skimage as ski; ski.data.download_all()'
Additional help
------------------------------------------------------------------------------
If you still have questions, reach out through
- our `user forum <https://forum.image.sc/tags/scikit-image>`_
- our `developer forum <https://discuss.scientific-python.org/c/contributor/skimage>`_
- our `chat channel <https://skimage.zulipchat.com/>`_
To suggest a change in these instructions,
`please open an issue on GitHub <https://github.com/scikit-image/scikit-image/issues/new>`_.
Installing scikit-image for contributors
========================================
Your system needs a:
- C compiler,
- C++ compiler, and
- a version of Python supported by ``scikit-image`` (see
`pyproject.toml <https://github.com/scikit-image/scikit-image/blob/main/pyproject.toml#L14>`_).
First, `fork the scikit-image repository on GitHub <https://github.com/scikit-image/scikit-image/fork>`_.
Then clone your fork locally and set an ``upstream`` remote to point to the original scikit-image repository:
.. note::
We use ``git@github.com`` below; if you don't have SSH keys setup, use
``https://github.com`` instead.
.. code-block:: sh
git clone git@github.com:YOURUSERNAME/scikit-image
cd scikit-image
git remote add upstream git@github.com:scikit-image/scikit-image
All commands below are run from within the cloned ``scikit-image`` directory.
.. _build-env-setup:
Build environment setup
------------------------------------------------------------------------------
Set up a Python development environment tailored for scikit-image.
Here we provide instructions for two popular environment managers:
``venv`` (pip) and ``conda`` (miniforge).
venv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: sh
# 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, use ``skimage-dev\Scripts\activate``)
source ~/envs/skimage-dev/bin/activate
# Install development dependencies
pip install -r requirements.txt
pip install -r requirements/build.txt
# Install scikit-image in editable mode. In editable mode,
# scikit-image will be recompiled, as necessary, on import.
spin install -v
.. tip::
The above installs scikit-image into your environment, which makes
it accessible to IDEs, IPython, etc.
This is not strictly necessary; you can also build with:
.. code-block:: sh
spin build
In that case, the library is not installed, but is accessible via
``spin`` commands, such as ``spin test``, ``spin ipython``, ``spin run``,
etc.
conda
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We recommend installing conda using
`miniforge <https://github.com/conda-forge/miniforge>`_,
an alternative to Anaconda without licensing costs.
After installing miniforge:
.. code-block:: sh
# Create a conda environment with required dependencies
conda env create -f environment.yml
# Activate it
conda activate skimage-dev
# Install scikit-image in editable mode. In editable mode,
# scikit-image will be recompiled, as necessary, on import.
spin install -v
.. tip::
The above installs scikit-image into your environment, which makes
it accessible to IDEs, IPython, etc.
This is not strictly necessary; you can also build with:
.. code-block:: sh
spin build
In that case, the library is not installed, but is accessible via
``spin`` commands, such as ``spin test``, ``spin ipython``, ``spin run``,
etc.
Testing
-------
Run the complete test suite:
.. code-block:: sh
spin test
Or run a subset of tests:
.. code-block:: sh
# Run tests in a given file
spin test skimage/morphology/tests/test_gray.py
# Run tests in a given directory
spin test skimage/morphology
# Run tests matching a given expression
spin test -- -k local_maxima
Adding a feature branch
------------------------------------------------------------------------------
When contributing a new feature, do so via a feature branch.
First, fetch the latest source:
.. code-block:: sh
git switch main
git pull upstream main
Create your feature branch:
.. code-block:: sh
git switch --create my-feature-name
Using an editable install, ``scikit-image`` will rebuild itself as
necessary.
If you are building manually, rebuild with::
.. code-block:: sh
spin build
Repeated, incremental builds usually work just fine, but if you notice build
problems, rebuild from scratch using:
.. code-block:: sh
spin build --clean
Platform-specific notes
------------------------------------------------------------------------------
**Windows**
Building ``scikit-image`` on Windows is done as part of our continuous
integration testing; the steps are shown in this `Azure Pipeline`_.
.. _Azure Pipeline: https://github.com/scikit-image/scikit-image/blob/main/azure-pipelines.yml
**Debian and Ubuntu**
Install suitable compilers prior to library compilation:
.. code-block:: sh
sudo apt-get install build-essential
Full requirements list
----------------------
**Build Requirements**
.. include:: ../../../requirements/build.txt
:literal:
**Runtime Requirements**
.. include:: ../../../requirements/default.txt
:literal:
**Test Requirements**
.. include:: ../../../requirements/test.txt
:literal:
**Documentation Requirements**
.. include:: ../../../requirements/docs.txt
:literal:
**Developer Requirements**
.. include:: ../../../requirements/developer.txt
:literal:
**Data Requirements**
The full selection of demo datasets is only available with the
following installed:
.. include:: ../../../requirements/data.txt
:literal:
**Optional Requirements**
You can use ``scikit-image`` with the basic requirements listed above, but some
functionality is only available with the following installed:
* `Matplotlib <https://matplotlib.org>`__
Used in various functions, e.g., for drawing, segmenting, reading images.
* `Dask <https://dask.org/>`__
The ``dask`` module is used to parallelize certain functions.
More rarely, you may also need:
* `PyAMG <https://pyamg.org/>`__
The ``pyamg`` module is used for the fast ``cg_mg`` mode of random
walker segmentation.
* `Astropy <https://www.astropy.org>`__
Provides FITS I/O capability.
* `SimpleITK <http://www.simpleitk.org/>`__
Optional I/O plugin providing a wide variety of `formats <https://itk.org/Wiki/ITK_File_Formats>`__.
including specialized formats used in biomedical imaging.
.. include:: ../../../requirements/optional.txt
:literal:
Help with contributor installation
------------------------------------------------------------------------------
See `Additional help <#additional-help>`_ above.
|