Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update installation page #595

Merged
merged 26 commits into from
Dec 23, 2024
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 103 additions & 55 deletions content/en/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,149 @@ title: Installation
sidebar: false
---

Installations methods include:
The recommended method of installing SciPy depends on your preferred workflow.
The common workflows can roughly be broken down into the following
categories:

- [Distributions](#distributions)
- [pip](#pip-install)
- [conda](#pip-install)
- [Package Manager](#package_manager)
- [Source](#source)
- [Environment-based (e.g. `pip`, `conda`)](#environment-based) (the traditional workflow)
- [Project-based (e.g. `uv`, `pixi`)](#project-based) (recommended for new users)
- [System package managers](#system-package-managers) (simplest)
- [Building from source](#building-from-source) (for debugging and development)

Methods differ in ease of use, coverage, maintenance of old versions,
system-wide versus local environment use, and control. With pip or
Anaconda\'s conda, you can control the package versions for a specific
project to prevent conflicts. Conda also controls non-Python packages,
like MKL or HDF5. System package managers, like `apt-get`, install
across the entire computer, often have older versions, and don\'t have
as many available versions. Source compilation is much more difficult
but is necessary for debugging and development. If you don\'t know which
installation method you need or prefer, we recommend the Scientific
Python Distribution [Anaconda](https://www.anaconda.com/download/).
To install SciPy with [static type stubs],
see [Installing with type stubs](#type-stubs).

<a name="distributions"></a>
[static type stubs]: https://typing.readthedocs.io/en/latest/guides/libraries.html

# Scientific Python Distributions (recommended)
<a name="environment-based"></a>

Python distributions provide the language itself, along with the most
commonly used packages and tools. These downloadable files require
little configuration, work on almost all setups, and provide all the
commonly used scientific Python tools.
## Environment-based workflows

[Anaconda](https://www.anaconda.com/download/) works on Windows, Mac,
and Linux, provides over 1,500 Python packages, and is used by over 15
million people. Anaconda is best suited to beginning users; it provides
a large collection of libraries all in one.
In environment-based workflows, you install packages into an environment, which you
can activate and deactivate.

For more advanced users who will need to install or upgrade regularly,
[Mambaforge](https://github.com/conda-forge/miniforge#mambaforge) is a more
suitable way to install the `conda` (and `mamba`, a faster `conda` alternative)
package manager.
If you have installed Python, you can create a virtual environment with a tool such
as `venv` - see [the tutorial in the Python Packaging User Guide][venv-guide].
You can then install [SciPy from PyPI], the Python Package Index, with [`pip`]:

Other options include:
python -m pip install scipy

- [WinPython](https://winpython.github.io): Another free distribution
including scientific packages and the Spyder IDE; Windows only, but
more actively maintained and supports the latest Python 3 versions.
- [Pyzo](https://pyzo.org): A free distribution based on Anaconda
and the IEP interactive development environment; Supports Linux,
Windows, and Mac.
[venv-guide]: https://packaging.python.org/en/latest/tutorials/installing-packages/#creating-virtual-environments
[SciPy from PyPI]: https://pypi.org/project/scipy/
[`pip`]: https://pip.pypa.io/en/stable/getting-started/

<a name="pip-install"></a>
Alternatively, you can install [SciPy from conda-forge] using a [Conda]-based
environment manager. You can install Python itself, as well as packages in
languages other than Python, as Conda packages.

# Installing with Pip
[Miniforge] is the recommended way to install `conda` and [`mamba`],
two Conda-based environment managers. You can then install SciPy as follows:

You can install SciPy from PyPI with `pip`:
conda install scipy # or
mamba install scipy

python -m pip install scipy
[SciPy from conda-forge]: https://anaconda.org/conda-forge/scipy
[Miniforge]: https://conda-forge.org/download/
[Conda]: https://docs.conda.io/projects/conda/en/latest/index.html
[`mamba`]: https://mamba.readthedocs.io/en/latest/

<a name="project-based"></a>

## Project-based workflows

In project-based workflows, a project is a directory containing a manifest
file describing the project, a lock-file describing the exact dependencies
of the project, and the project's (potentially multiple) environments.
These workflows provide reproducibility benefits over environment-based workflows.

You can add [SciPy from PyPI] to a [`uv`] project:

uv add scipy

You can also install Python itself with `uv`.

[`uv`]: https://docs.astral.sh/uv/

If you work with non-Python packages, you may prefer to install SciPy as
a Conda package, so that you can use the same workflow for packages which
are not available on PyPI.

<a name="conda-install"></a>
You can add [SciPy from conda-forge] to a [`pixi`] project:

# Installing via Conda
pixi add scipy

You can install SciPy from the `defaults` or `conda-forge` channels with `conda`:
Pixi can also install packages from PyPI, using `uv` under the hood.

conda install scipy
[`pixi`]: https://pixi.sh/latest/

<a name="package_manager"></a>
<a name="system-package-managers"></a>

# Install system-wide via a package manager
## Installing system-wide via a system package manager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these methods are so problematic, we could consider only keeping the first sentence (warning) and not giving individual instructions for Debian, Fedora, and macos here.

Optionally, we could then show the route I mentioned elsewhere, which works perfectly well: install Python via system and then just create a virtual env using python -m venv. Since this page is no longer the beginner guide, I think that should be acceptable?

The suggestion is not needed for this PR, but if it seems like a sensible suggestion I'm happy to make a follow-up PR in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these methods are so problematic, we could consider only keeping the first sentence (warning) and not giving individual instructions for Debian, Fedora, and macos here.

I would be happy with that, let's see what others think.

Optionally, we could then show the route I mentioned elsewhere, which works perfectly well: install Python via system and then just create a virtual env using python -m venv. Since this page is no longer the beginner guide, I think that should be acceptable?

How does that differ from https://deploy-preview-595--scipy-org.netlify.app/install/#installing-with-pip? Just installing Python with a system package manager rather than python.org? I said in another thread that I would be happy to remove the hyperlink to python.org, but I thought that listing out options for installing Python might be overkill.

The suggestion is not needed for this PR, but if it seems like a sensible suggestion I'm happy to make a follow-up PR in the future.

👍


System package managers can install the most common Python packages.
They install packages for the entire computer, often use older versions,
and don't have as many available versions.
and don't have as many available versions. They are not the recommended
installation method, but they are the simplest.

## Ubuntu and Debian
### Ubuntu and Debian

Using `apt-get`:

sudo apt-get install python3-scipy

## Fedora
### Fedora

Using `dnf`:

sudo dnf install python3-scipy

## macOS
### macOS

macOS doesn't have a preinstalled package manager, but you can install
[Homebrew](https://brew.sh/) and use it to install SciPy (and Python itself):

brew install scipy

<a name="source"></a>
<a name="building-from-source"></a>

# Source packages
## Building from source

A word of warning: building SciPy from source can be a nontrivial exercise. We
recommend using binaries instead if those are available for your platform.
recommend using binaries instead if those are available for your platform
via one of the above methods.
For details on how to build from source, see
[this guide in the SciPy docs](https://scipy.github.io/devdocs/building/index.html).
[the building from source guide in the SciPy docs][building-docs].

[building-docs]: https://scipy.github.io/devdocs/building/index.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the default recommendation to use uv for projects, I was wondering whether, in the future, we should adjust the above page accordingly?

I presume it can be used the same way pip is for SciPy development, adding a third code tab with uv run python dev.py and uv pip for installing dependencies?

Copy link
Member Author

@lucascolley lucascolley Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the default recommendation to use uv for projects, I was wondering whether, in the future, we should adjust the above page accordingly?

Yep! Although for SciPy, given the compiler dependencies, Pixi will probably be our best bet. I already use https://github.com/rgommers/pixi-dev-scipystack for all of my SciPy development. Windows support for PyTorch and JAX on conda-forge is still maturing (though actively - conda-forge/pytorch-cpu-feedstock#231), but we may be able to use PyPI on Windows to fill some gaps if anyone needs it.

A third tab for uv is probably not so useful, since it's relatively obvious what to do by following along with the pip instructions, and you have to do the same setup of system deps.

I presume it can be used the same way pip is for SciPy development, adding a third code tab with uv run python dev.py and uv pip for installing dependencies?

All that to say that we could do something like this. Or we could make a new page instead of adding a new tab, since there is much less to explain when most of the work is already done in writing the Pixi manifest. We may want to wait until somebody wants to try to merge Pixi support into the main repo, though.


Also I plan to add a note about scipy-stubs to the building from source page after this is merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Lucas!


<a name="type-stubs"></a>

## Installing with type stubs

Static type stubs are available via a separate package, `scipy-stubs`, on
PyPI and conda-forge. If you have already installed SciPy, you just need to
install `scipy-stubs` in the same way:

python -m pip install scipy-stubs # or
uv add scipy-stubs # or
conda install scipy-stubs # or
pixi add scipy-stubs

<!---
XXX: https://github.com/conda-forge/scipy-stubs-feedstock/pull/5
-->

You can also install SciPy and `scipy-stubs` as a single package,
via the `scipy-stubs[scipy]` extra on PyPI, or the `scipy-typed`
package on conda-forge.
To get a specific version `x.y.z` of SciPy (such as `1.14.1`),
you should install version `x.y.z.*` below:

python -m pip install "scipy-stubs[scipy]" # or
# versions for illustrative purposes
uv add "scipy-stubs[scipy]==1.14.1.*" # or
conda install "scipy-typed>=1.14" # or
pixi add "scipy-typed=1.15.0.*"

Please direct questions about static typing support to
[the `scipy-stubs` GitHub repository](https://github.com/jorenham/scipy-stubs).
Loading