Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update installation page content
  • Loading branch information
melissawm committed Jan 15, 2026
commit a4967109d9b35478af2337091caf076c2d8a77c4
2 changes: 1 addition & 1 deletion content/en/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Installing NumPy
sidebar: false
---

{{< admonition tip >}}
This page assumes you are comfortable using a terminal and are familiar with package managers.
The only prerequisite for installing NumPy is Python itself. If you don't have
Expand Down Expand Up @@ -128,4 +129,3 @@ IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed. This error can happen for
different reasons, often due to issues with your setup.
```

210 changes: 108 additions & 102 deletions content/ja/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,123 +3,129 @@ title: NumPyのインストール
sidebar: false
---

NumPyは`conda`、`pip` 、macOSやLinuxのパッケージマネージャー、または [ソースコード](https://numpy.org/devdocs/building)からインストールすることが出来ます。 詳細な手順については、以下の [Python と Numpyの インストールガイド](#python-numpy-install-guide) を参照してください。

NumPyは`conda`、`pip` 、macOSやLinuxのパッケージマネージャー、または [ソースコード](https://numpy.org/devdocs/user/building.html)からインストールすることが出来ます。 NumPyをインストールするための唯一必要なものは、Pythonそのものだけです。 もしまだPythonをイントールしておらず、最もシンプルなインストール方法をお探しなら、[Anaconda Distribution](https://www.anaconda.com/distribution)の使用をおすすめします。

**CONDA**

`conda`を使用する場合、 `defaults` または `conda-forge` のチャンネルから NumPy をインストールできます。

{{< admonition tip >}}
This page assumes you are comfortable using a terminal and are familiar with package managers.
The only prerequisite for installing NumPy is Python itself. If you don't have
Python yet and want the simplest way to get started, we recommend you use the
[Anaconda Distribution](https://www.anaconda.com/download) - it includes
Python, NumPy, and many other commonly used packages for scientific computing
and data science.
{{< /admonition >}}

The recommended method of installing NumPy depends on your preferred workflow. Below, we break down the installation methods into the following categories:

- **Project-based** (e.g., uv, pixi) *(recommended for new users)*
- **Environment-based** (e.g., pip, conda) *(the traditional workflow)*
- **System package managers** *(not recommended for most users)*
- **Building from source** *(for advanced users and development purposes)*

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

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

[[tab]]
name = 'Project Based'
content = '''

Recommended for new users who want a streamlined workflow.

- **uv:** A modern Python package manager designed for speed and simplicity.
```bash
uv pip install numpy
```

- **pixi:** A cross-platform package manager for Python and other languages.
```bash
pixi add numpy
```

'''

[[tab]]
name = 'Environment Based'
content = '''

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.

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.

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.

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.

- **Conda:** If you use conda, you can install NumPy from the defaults or conda-forge channels:
```bash
conda create -n my-env
conda activate my-env
conda install numpy
```
- **Pip:**
```bash
pip install numpy
```
{{< admonition tip >}}
**Tip:** Use a virtual environment for better dependency management
{{< /admonition >}}

```bash
python -m venv my-env
source my-env/bin/activate # macOS/Linux
my-env\Scripts\activate # Windows
pip install numpy
```
'''

[[tab]]
name = 'System Package Managers'
content = '''
Not recommended for most users, but available for convenience.

**macOS (Homebrew):**
```bash
# base envにインストールするのでなく、environmentを作成するのがベストプラクティスです
conda create -n my-env
conda activate my-env
# conda-forgeからインストールする場合
conda config --env --add channels conda-forge
# インストールコマンド
conda install numpy
brew install numpy
```

**PIP**

`pip`を使用する場合、以下のようにNumPyをインストールできます:

**Linux (APT):**
```bash
pip install numpy
sudo apt install python3-numpy
```
**Windows (Chocolatey):**
```bash
choco install numpy
```
またpipを使う場合、仮想環境を使うことをおすすめします。 [再現可能なインストール](#reproducible-installs)を参照ください。 [こちらの記事](https://dev.to/bowmanjd/python-tools-for-managing-virtual-environments-3bko#howto)では仮想環境を使う詳細について説明されています。


<a name="python-numpy-install-guide"></a>

# PythonとNumPyの インストールガイド

Pythonパッケージのインストールと管理は複雑なので、ほとんどのタスクには数多くの代替ツールがあります。 このガイドでは、読者に最適な(または最も人気のある) 方法と明確な指針を提供したいと思います。 このガイドでは、一般的なオペレーティングシステムとハードウェア上での、 Python、NumPy、PyData (または数値計算) スタックのユーザに焦点を当てています。

## 推奨方法

まずはユーザの経験レベルと、関心のあるOSに基づいた推奨方法から説明していきたいと思います。 PythonやNumPyの経験が「初級」と「上級」の間の方は、シンプルにインストールしたい場合は「初級」を、より長い視点にたったベストプラクティスに沿ってインストールしたい方は「上級」を参照ください。

### 初級ユーザ

Windows、macOS、Linuxのすべてのユーザー向けには:

- [Anaconda](https://www.anaconda.com/distribution/) をインストールします(必要な パッケージと以下に挙げるすべてのツールがインストールされます)。
- コードを書いたり、実行してみましょう。 探索的・対話的コンピューティングには[JupyterLab](https://jupyterlab.readthedocs.io/en/stable/index.html)のノートブックが便利です。 スクリプトやパッケージの作成には[Spyder](https://www.spyder-ide.org/)や[Visual Studio Code](https://code.visualstudio.com/)を利用できます。
- [Anaconda Navigator](https://docs.anaconda.com/anaconda/navigator/) を使ってパッケージを管理し、JupyterLab、Spyder、Visual Studio Codeを使い始められます。


### 上級ユーザー

#### Conda

- [Miniforge](https://github.com/conda-forge/miniforge) をインストールします。
- `base` のconda環境を出来るだけ小さく保って下さい。 そして、一つか二つ個別の[`conda environment`](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)を使って、作業中のタスクやプロジェクトに必要なパッケージをインストールしましょう。

#### pip/PyPI を利用したい場合

個人的な好みや、下記のcondaとpipの違いを理解した上で、pip/PyPIベースの方法を使いたいユーザーには、下記をお勧めします:
- [python.org](https://www.python.org/downloads/)からや、Macを使っている場合は[Homebrew](https://brew.sh/)、 Linuxを使っている場合は、Linuxのパッケージマネージャーを使ってPythonをインストールします。
- 依存関係の解決と環境の管理を提供する最もよくメンテナンスされているツールとして、[Poetry](https://python-poetry.org/) をconda と同様な方法で使用することができます。


## Pythonにおけるパッケージ管理

パッケージの管理は難しいため、たくさんのツールが存在しています。 ウェブ開発と汎用的なPython開発には、こちらのようなpipを補完する [ツール](https://packaging.python.org/guides/tool-recommendations/) があります。 ハイパフォーマンスコンピューティング(HPC)では、 [Spack](https://github.com/spack/spack) を使うことを検討して下さい。 NumPyのほとんどのユーザーにとっては、 [conda](https://conda.io/en/latest/) と [pip](https://pip.pypa.io/en/stable/) が最も広く利用されているツールです。


### Pipとconda

`pip` と `conda` がPythonパッケージをインストールするための2つの主要なツールです。 これら二つのツールの機能は部分的に重複しますが(例えば、両方とも `numpy`をインストールできます)、一緒に動作することもできます。 ここでは、pip とcond の主要な違いについて説明します。 これは、パッケージをどのように効果的に管理するかを理解したい場合、重要な知識です。

2つ目の違いは、pipはPython Packaging Index(PyPI) からパッケージをインストールするのに対し、condaは独自のチャンネル(一般的には "defaults "や "conda-forge "など) からインストールすることです。 PyPIは最大のパッケージ管理システムですが、人気のある全てのパッケージがcondaでも利用可能です。

最初の違いは、condaは複数言語に対応可能で、Python自体をインストールできることです。 pip はシステム上の特定の Python にインストールされ、パッケージはそのPython用にのみインストールします。 PyPIは、最大のパッケージ管理システムですが、すべての代表的なパッケージは、condaにも利用可能です。

3つ目の違いは、condaはパッケージ、依存関係、環境を管理するための統合されたソリューションであるのに対し、pipでは環境や複雑な依存関係を扱うために別のツール(たくさん存在しています!

<a name="reproducible-installs"></a>

### 再現可能なインストール

ライブラリが更新されると、コードの実行結果が変わったり、コードが完全に 壊れたりする可能性があります。 なので重要なことは、使用しているパッケージの組み合わせと各バージョンのセットを再構築できるようにしておくことです。 ベストプラクティスは次の通りです:

1. プロジェクトごとに異なる仮想環境を使用して下さい。
2. パッケージインストーラを使用してパッケージ名とバージョンを記録するようにして下さい。 それぞれ、独自のメタデータフォーマットがあります:
- condaの場合: [conda environmentsとenvironment.yml](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
- pipの場合: [仮想環境](https://docs.python.org/3/tutorial/venv.html) と [requirements.txt](https://pip.readthedocs.io/en/latest/user_guide/#requirements-files)
- poetryの場合: [仮想環境とpyproject.toml](https://python-poetry.org/docs/basic-usage/)



## NumPyパッケージと高速線形代数ライブラリ

NumPy は他の Python パッケージに依存していませんが、高速な線形代数ライブラリに依存しています。 典型的には、[インテル® MKL](https://software.intel.com/en-us/mkl)や[OpenBLAS](https://www.openblas.net/)がこれにあたります。 ユーザーは、これらの線形代数ライブラリのインストールを心配する必要はありません (NumPyのインストール方法に、あらかじめ含まれているためです)。 高度なユーザーは、使用されているBLASがパフォーマンスや、動作、ディスク上のサイズに影響を与えるため、より詳細を知りたがるかもしれません。

- pipでインストールされるPyPI上の NumPy wheelは、OpenBLASを使ってビルドされます。 つまりwheelにはOpenBLASライブラリが含まれています。 そのため、ユーザが(例えば)SciPyも同じようにインストールした場合、ディスク上にOpenBLASのコピーをNumPyのものと2つ持つことになります

- condaのデフォルトチャンネルでは、NumPy はインテル® MKLを使ってビルドされます。 MKLはNumPyのインストール時に、独立したパッケージとしてユーザー環境にインストールされます。
'''

- conda-forgeのチャンネルでは、NumPyはダミーの「BLAS」パッケージを使ってビルドされています。 ユーザーがconda-forgeからNumPyをインストールすると、BLASパッケージが実際のライブラリと一緒にインストールされます。 デフォルトはOpenBLASですが、MKL(default チャンネルの場合)や [BLIS](https://github.com/flame/blis)、またはBLASを利用することもできます。
[[tab]]
name = 'Building from Source'
content = '''
For advanced users and developers who want to customize or debug **NumPy**.

- OpenBLASは約30MBですが、MKLパッケージはOpenBLASよりもはるかに大きく、ディスク上の約700MBです。
A word of warning: building Numpy from source can be a nontrivial exercise.
We 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 [the building from source guide in the Numpy docs](https://numpy.org/devdocs/building/).

- MKLは通常、OpenBLASよりも少し速く、より安定した解を得られます。
'''
{{< /tabs >}}

インストールサイズ、パフォーマンスとロバスト性に加えて、考慮すべき2つの点があります:
## Verifying the Installation

- インテル® MKL はオープンソースではありません。 通常の使用では問題ではありませんが、 ユーザーが NumPy で構築されたアプリケーションを再配布する必要がある場合、これは 問題が発生する可能性があります。
- MKLとOpenBLASの両方とも、 <code>np.dot</code>のような関数呼び出しにマルチスレッドを使用し、スレッド数はビルド時オプションと環境変数の両方で決定されます。 多くの場合、すべての CPU コアが使用されます。 これにユーザーにとっては予想外のことかもしれません。 NumPy 自体は、関数呼び出しを自動的に並列化しないからです。 自動並列化により、一般にはパフォーマンスが向上しますが、逆にパフォーマンスが悪化する場合もあります。 例えば、Daskやscikit-learn、multiprocessingなど別のレベルの並列化を使用している場合です。
After installing NumPy, verify the installation by running the following in a Python shell or script:
```python
import numpy as np
print(np.__version__)
```

This should print the installed version of NumPy without errors.

## トラブルシューティング
## Troubleshooting

インストールに失敗した場合に、下記のエラーメッセージが表示される場合は、 <a href="https://numpy.org/doc/stable/user/troubleshooting-importerror.html">トラブルシューティング ImportError</a> を参照してください。
If your installation fails with the message below, see [Troubleshooting
ImportError](https://numpy.org/doc/stable/user/troubleshooting-importerror.html).

```
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed. This error can happen for different reasons, often due to issues with your setup.
Importing the numpy c-extensions failed. This error can happen for
different reasons, often due to issues with your setup.
```