English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

NumPy 安装

NumPy Installationsanleitung

Die Distributionen auf der Python-Website enthalten keine NumPy-Module. Die einzige Voraussetzung für NumPy ist Python selbst. Wenn Sie noch keinen Python haben und auf einfache Weise beginnen möchten, empfehlen wir Ihnen,Anaconda-Version -Dies enthält Python, NumPy und andere gängige Softwarepakete für wissenschaftliche Berechnungen und Datenwissenschaften, und die spezifische Installation können wir mit folgenden Methoden durchführen.

1、Verwenden Sie die bestehende Version

Für viele Benutzer, insbesondere auf Windows, ist der einfachste Weg, die folgenden Python-Versionen herunterzuladen, die alle erforderlichen Pakete enthalten (einschließlich NumPy, SciPy, matplotlib, IPython, SymPy und andere Pakete, die im Python-Kern enthalten sind):

Anaconda: Kostenlose Python-Version, die für massive Datenverarbeitung, Vorhersageanalyse und wissenschaftliche Berechnungen verwendet wird, und sich der Vereinfachung der Verwaltung und Bereitstellung von Paketen widmet. Unterstützt Linux, Windows und Mac-Systeme.Enthought Canopy: Bietet kostenlose und kommerzielle Versionen. Unterstützt Linux, Windows und Mac-Systeme.Python(x, y): Kostenlose Python-Version, die den vollständigen Python-Entwicklungspackage und das Spyder IDE enthält. Unterstützt Windows, nur für Python 2 version.WinPython: Another free Python distribution that includes scientific computing packages and Spyder IDE. Supports Windows.Pyzo: Free distribution version based on Anaconda and interactive development environment IEP, ultra-lightweight. Supports Linux, Windows, and Mac systems.

2and using conda/pip installation

pip is a Python package management tool that provides the functions of searching, downloading, installing, and uninstalling Python packages.
Currently, if you are https://www.python.org If you download the latest version of the installation package, it means that the tool is already included.
Python 2.7.9 + or Python 3.4+ All these versions come with the pip tool.
The official website of pip:https://pypi.org/project/pip
You can use the following command to determine whether it is installed:

Install using pip

Before installing with pip, you need to check if pip is already installed, the specific command is as follows:

pip --version  # Python2.x version command
pip3 --version  # Python3.x version command

If you have not installed it yet, you can use the following method to install:

$ curl https://bootstrap.pypa.io/get-pip.py -o  get-pip.py  # Download the installation script
$ sudo python get-pip.py  # Run the installation script
$ sudo python3 get-pip.py  # Run the installation script.
Note:The version of Python used to run the installation script associates pip with that version, if it is Python3 Then execute the above command.

Generally, pip corresponds to Python 2.7,pip3 This corresponds to Python 3.x.

If pip has been installed, you can use the following command to install:

pip3 install --user  numpy  scipy  matplotlib

--The 'user' option can be set to install only in the current user, not in the system directory.
By default, use overseas routes, but overseas is too slow, so we use Tsinghua's mirror:

If you use conda, you can use the following commands to install:

pip3 install numpy scipy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

Install using conda

conda is divided into anaconda and miniconda. Anaconda is a version that includes some commonly used packages, while miniconda is a streamlined version that you can install what you need, so it is recommended to use miniconda.
The official website of miniconda:https://conda.io/miniconda.html Select the version that suits you and download and install it.

使用conda安装numpy的具体命令如下:

conda install numpy

Linux 下安装Numpy

Ubuntu & Debian

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

CentOS/Fedora

sudo dnf install numpy scipy python-matplotlib ipython python-pandas sympy python-nose atlas-devel

Mac 系统

pip3 install numpy scipy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

安装验证

通过以下操作对Numpy安装是否成功进行测试,具体代码如下:

>>> import numpy as np
>>> print(np.__version__)
1.19.1
>>> arr = np.array([1, 2, 3, 4, 5)
>>> print(arr)
[1 2 3 4 5]