Skip to content

Commit 1ec6b0c

Browse files
updated the whole page like Scipy
1 parent e750847 commit 1ec6b0c

File tree

1 file changed

+86
-166
lines changed

1 file changed

+86
-166
lines changed

content/en/install.md

Lines changed: 86 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -2,207 +2,127 @@
22
title: Installing NumPy
33
sidebar: false
44
---
5-
5+
{{< admonition tip >}}
6+
This page assumes you are comfortable using a terminal and are familiar with package managers.
67
The only prerequisite for installing NumPy is Python itself. If you don't have
78
Python yet and want the simplest way to get started, we recommend you use the
89
[Anaconda Distribution](https://www.anaconda.com/download) - it includes
910
Python, NumPy, and many other commonly used packages for scientific computing
1011
and data science.
12+
{{< /admonition >}}
1113

12-
NumPy can be installed with `conda`, with `pip`, with a package manager on
13-
macOS and Linux, or [from source](https://numpy.org/devdocs/building).
14-
For more detailed instructions, consult our [Python and NumPy
15-
installation guide](#python-numpy-install-guide) below.
16-
17-
**CONDA**
14+
The recommended method of installing NumPy depends on your preferred workflow. Below, we break down the installation methods into the following categories:
1815

19-
If you use `conda`, you can install NumPy from the `defaults` or `conda-forge`
20-
channels:
21-
22-
```bash
23-
# Best practice, use an environment rather than install in the base env
24-
conda create -n my-env
25-
conda activate my-env
26-
# If you want to install from conda-forge
27-
conda config --env --add channels conda-forge
28-
# The actual install command
29-
conda install numpy
30-
```
31-
32-
**PIP**
33-
34-
If you use `pip`, you can install NumPy with:
35-
36-
```bash
37-
pip install numpy
38-
```
39-
Also when using pip, it's good practice to use a virtual environment -
40-
see [Reproducible Installs](#reproducible-installs) below for why, and
41-
[this guide](https://dev.to/bowmanjd/python-tools-for-managing-virtual-environments-3bko#howto)
42-
for details on using virtual environments.
16+
- **Project-based** (e.g., uv, pixi) *(recommended for new users)*
17+
- **Environment-based** (e.g., pip, conda) *(the traditional workflow)*
18+
- **System package managers** *(not recommended for most users)*
19+
- **Building from source** *(for advanced users and development purposes)*
4320

21+
Choose the method that best suits your needs. If you're unsure, start with the **Environment-based** method using `conda` or `pip`.
4422

45-
<a name="python-numpy-install-guide"></a>
46-
# Python and NumPy installation guide
4723

48-
Installing and managing packages in Python is complicated, there are a
49-
number of alternative solutions for most tasks. This guide tries to give the
50-
reader a sense of the best (or most popular) solutions, and give clear
51-
recommendations. It focuses on users of Python, NumPy, and the PyData (or
52-
numerical computing) stack on common operating systems and hardware.
24+
NumPy can be installed with a `package manager` on
25+
macOS and Linux, or [from source](https://numpy.org/devdocs/building).
26+
For more detailed instructions, consult our **Python and NumPy
27+
installation** guide below.
5328

29+
Below are the different methods for **installing NumPy**. Click on the tabs to explore each method:
5430
{{< tabs >}}
5531

5632
[[tab]]
57-
name = 'Recommended Method'
33+
name = 'Project Based'
5834
content = '''
5935

60-
We'll start with recommendations based on the user's experience level and
61-
operating system of interest. If you're in between "beginning" and "advanced",
62-
please go with "beginning" if you want to keep things simple, and with
63-
"advanced" if you want to work according to best practices that go a longer way
64-
in the future.
65-
66-
### Beginning users
67-
68-
On all of Windows, macOS, and Linux:
69-
70-
- Install [Anaconda](https://www.anaconda.com/download) (it installs all
71-
packages you need and all other tools mentioned below).
72-
- For writing and executing code, use notebooks in
73-
[JupyterLab](https://jupyterlab.readthedocs.io/en/stable/index.html) for
74-
exploratory and interactive computing, and
75-
[Spyder](https://www.spyder-ide.org/) or [Visual Studio Code](https://code.visualstudio.com/)
76-
for writing scripts and packages.
77-
- Use [Anaconda Navigator](https://docs.anaconda.com/anaconda/navigator/) to
78-
manage your packages and start JupyterLab, Spyder, or Visual Studio Code.
79-
36+
Recommended for new users who want a streamlined workflow.
8037

81-
### Advanced users
38+
- **uv:** A modern Python package manager designed for speed and simplicity.
39+
```bash
40+
uv pip install numpy
41+
```
8242

83-
#### Conda
84-
85-
- Install [Miniforge](https://github.com/conda-forge/miniforge).
86-
- Keep the `base` conda environment minimal, and use one or more
87-
[conda environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
88-
to install the package you need for the task or project you're working on.
89-
90-
#### Alternative if you prefer pip/PyPI
91-
92-
For users who know, from personal preference or reading about the main
93-
differences between conda and pip below, they prefer a pip/PyPI-based solution,
94-
we recommend:
95-
- Install Python from [python.org](https://www.python.org/downloads/),
96-
[Homebrew](https://brew.sh/), or your Linux package manager.
97-
- Use [Poetry](https://python-poetry.org/) as the most well-maintained tool
98-
that provides a dependency resolver and environment management capabilities
99-
in a similar fashion as conda does.
43+
- **pixi:** A cross-platform package manager for Python and other languages.
44+
```bash
45+
pixi add numpy
46+
```
10047

10148
'''
10249

10350
[[tab]]
104-
name = 'Python Package Management'
51+
name = 'Environment Based'
10552
content = '''
10653

107-
Managing packages is a challenging problem, and, as a result, there are lots of
108-
tools. For web and general purpose Python development there's a whole
109-
[host of tools](https://packaging.python.org/guides/tool-recommendations/)
110-
complementary with pip. For high-performance computing (HPC),
111-
[Spack](https://github.com/spack/spack) is worth considering. For most NumPy
112-
users though, [conda](https://conda.io/en/latest/) and
113-
[pip](https://pip.pypa.io/en/stable/) are the two most popular tools.
114-
115-
116-
### Pip & conda
117-
118-
The two main tools that install Python packages are `pip` and `conda`. Their
119-
functionality partially overlaps (e.g. both can install `numpy`), however, they
120-
can also work together. We'll discuss the major differences between pip and
121-
conda here - this is important to understand if you want to manage packages
122-
effectively.
123-
124-
The first difference is that conda is cross-language and it can install Python,
125-
while pip is installed for a particular Python on your system and installs other
126-
packages to that same Python install only. This also means conda can install
127-
non-Python libraries and tools you may need (e.g. compilers, CUDA, HDF5), while
128-
pip can't.
129-
130-
The second difference is that pip installs from the Python Packaging Index
131-
(PyPI), while conda installs from its own channels (typically "defaults" or
132-
"conda-forge"). PyPI is the largest collection of packages by far, however, all
133-
popular packages are available for conda as well.
134-
135-
The third difference is that conda is an integrated solution for managing
136-
packages, dependencies and environments, while with pip you may need another
137-
tool (there are many!) for dealing with environments or complex dependencies.
138-
139-
<a name="reproducible-installs"></a>
140-
141-
### Reproducible installs
142-
143-
As libraries get updated, results from running your code can change, or your
144-
code can break completely. It's important to be able to reconstruct the set
145-
of packages and versions you're using. Best practice is to:
54+
The two main tools that install Python packages are `pip` and `conda`. Their functionality partially overlaps (e.g. both can install `numpy`), however, they can also work together. We’ll discuss the major differences between pip and conda here - this is important to understand if you want to manage packages effectively.
55+
56+
The first difference is that conda is cross-language and it can install Python, while pip is installed for a particular Python on your system and installs other packages to that same Python install only. This also means conda can install non-Python libraries and tools you may need (e.g. compilers, CUDA, HDF5), while pip can’t.
57+
58+
The second difference is that pip installs from the Python Packaging Index (PyPI), while conda installs from its own channels (typically “defaults” or “conda-forge”). PyPI is the largest collection of packages by far, however, all popular packages are available for conda as well.
59+
60+
The third difference is that conda is an integrated solution for managing packages, dependencies and environments, while with pip you may need another tool (there are many!) for dealing with environments or complex dependencies.
61+
62+
- **Conda:** If you use conda, you can install NumPy from the defaults or conda-forge channels:
63+
```bash
64+
conda create -n my-env
65+
conda activate my-env
66+
conda install numpy
67+
```
68+
- **Pip:**
69+
```bash
70+
pip install numpy
71+
```
72+
{{< admonition tip >}}
73+
**Tip:** Use a virtual environment for better dependency management
74+
{{< /admonition >}}
75+
76+
```bash
77+
python -m venv my-env
78+
source my-env/bin/activate # macOS/Linux
79+
my-env\Scripts\activate # Windows
80+
pip install numpy
81+
```
82+
'''
14683

147-
1. use a different environment per project you're working on,
148-
2. record package names and versions using your package installer;
149-
each has its own metadata format for this:
150-
- Conda: [conda environments and environment.yml](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
151-
- Pip: [virtual environments](https://docs.python.org/3/tutorial/venv.html) and
152-
[requirements.txt](https://pip.readthedocs.io/en/latest/user_guide/#requirements-files)
153-
- Poetry: [virtual environments and pyproject.toml](https://python-poetry.org/docs/basic-usage/)
84+
[[tab]]
85+
name = 'System Package Managers'
86+
content = '''
87+
Not recommended for most users, but available for convenience.
15488

89+
**macOS (Homebrew):**
90+
```bash
91+
brew install numpy
92+
```
93+
**Linux (APT):**
94+
```bash
95+
sudo apt install python3-numpy
96+
```
97+
**Windows (Chocolatey):**
98+
```bash
99+
choco install numpy
100+
```
155101

156102
'''
157103

158104
[[tab]]
159-
name = 'NumPy packages & Libraries'
105+
name = 'Building from Source'
160106
content = '''
107+
For advanced users and developers who want to customize or debug **NumPy**.
108+
109+
A word of warning: building Numpy from source can be a nontrivial exercise.
110+
We recommend using binaries instead if those are available for your platform via one of the above methods.
111+
For details on how to build from source, see [the building from source guide in the Numpy docs](https://numpy.org/devdocs/building/).
161112

162-
NumPy doesn't depend on any other Python packages, however, it does depend on an
163-
accelerated linear algebra library - typically
164-
[Intel MKL](https://software.intel.com/en-us/mkl) or
165-
[OpenBLAS](https://www.openblas.net/). Users don't have to worry about
166-
installing those (they're automatically included in all NumPy install methods).
167-
Power users may still want to know the details, because the used BLAS can
168-
affect performance, behavior and size on disk:
169-
170-
- The NumPy wheels on PyPI, which is what pip installs, are built with OpenBLAS.
171-
The OpenBLAS libraries are included in the wheel. This makes the wheel
172-
larger, and if a user installs (for example) SciPy as well, they will now
173-
have two copies of OpenBLAS on disk.
174-
175-
- In the conda defaults channel, NumPy is built against Intel MKL. MKL is a
176-
separate package that will be installed in the users' environment when they
177-
install NumPy.
178-
179-
- In the conda-forge channel, NumPy is built against a dummy "BLAS" package. When
180-
a user installs NumPy from conda-forge, that BLAS package then gets installed
181-
together with the actual library - this defaults to OpenBLAS, but it can also
182-
be MKL (from the defaults channel), or even
183-
[BLIS](https://github.com/flame/blis) or reference BLAS.
184-
185-
- The MKL package is a lot larger than OpenBLAS, it's about 700 MB on disk
186-
while OpenBLAS is about 30 MB.
187-
188-
- MKL is typically a little faster and more robust than OpenBLAS.
189-
190-
Besides install sizes, performance and robustness, there are two more things to
191-
consider:
192-
193-
- Intel MKL is not open source. For normal use this is not a problem, but if
194-
a user needs to redistribute an application built with NumPy, this could be
195-
an issue.
196-
- Both MKL and OpenBLAS will use multi-threading for function calls like
197-
`np.dot`, with the number of threads being determined by both a build-time
198-
option and an environment variable. Often all CPU cores will be used. This is
199-
sometimes unexpected for users; NumPy itself doesn't auto-parallelize any
200-
function calls. It typically yields better performance, but can also be
201-
harmful - for example when using another level of parallelization with Dask,
202-
scikit-learn or multiprocessing.
203113
'''
204114
{{< /tabs >}}
205115

116+
## Verifying the Installation
117+
118+
After installing NumPy, verify the installation by running the following in a Python shell or script:
119+
```python
120+
import numpy as np
121+
print(np.__version__)
122+
```
123+
124+
This should print the installed version of NumPy without errors.
125+
206126
## Troubleshooting
207127

208128
If your installation fails with the message below, see [Troubleshooting

0 commit comments

Comments
 (0)