How To Install Numpy On Macos, Linux And Windows

NumPy is a third-party extension package for Python, but it is not included in the python standard library, so you need to install it separately. This article will tell you how to install NumPy on macOS, Linux, and Windows.

1. Install NumPy On macOS.

  1. Although the MAC system comes with the package manager homebrew, it cannot download NumPy and other scientific computing packages, so NumPy needs to be installed with the below command.
  2. Open a terminal and run the command $ pip3 install numpy scipy matplotlib.

2. Install NumPy On Linux.

  1. In a Linux system, you can choose to install only one NumPy package or install multiple packages at the same time. The following describes the specific installation commands for different Linux distributions.
  2. Ubuntu/Debian: For Ubuntu / Debian system, you can execute the following commands on the terminal.
    $ sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
  3. Redhat/CentOS: Execute the following commands on the RedHat / CentOS system to install NumPy and other scientific computing packages. Note: different packages’ names must be separated by whitespace.
    $ sudo yum install numpy scipy python-matplotlib ipython python-pandas sympy python-nose

3. Install Numpy On Window.

  1. There are two common ways to install NumPy in Windows.
  2. Using Python package manager pip to install NumPy is the simplest and lightest method. Just execute the following command.
    pip install numpy

4. Verify Numpy Package Install Status.

  1. Finally, open the python interactive interpreter and import the NumPy module to verify whether the installation is successful.
  2. If the import command does not display any error, then it means the NumPy installation is successful.
    (MyPythonEnv) C:\Users\zhaosong>python
    Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    >>> import numpy
    >>>

5. SciPy Stack.

  1. In real projects, NumPy is usually used together with the SciPy package. SciPy can be regarded as an extension of the NumPy library, which adds many engineering calculation functions on the basis of NumPy. Therefore, it is a good choice to install them at the same time.
  2. Note: when installing SciPy directly using PIP under windows, an error will be reported. We need to solve the dependency problem of SciPy, so it is not recommended to use pip to install the SciPy package. The following describes how to install SciPy packages using the SciPy stack.

5.1 What is SciPy Stack.

  1. First, we need to know what is SciPy stack? In fact, it is an integrated platform for scientific computing software packages. This kind of platform includes common numerical computing and machine learning libraries, such as NumPy, Matplotlib, SciPy, IPython, etc., and it can automatically solve the dependency between packages. All the above software packages can be installed by installing an integrated platform.

5.2 Several Commonly Used SciPy Stacks.

  1. Anaconda: This is an open-source Python distribution, which contains more than 180 science packages such as NumPy and SciPy and their dependencies. In addition to supporting windows, it also supports Linux and MAC systems. Anaconda is widely used at present, so it is recommended to install it. The Anaconda official website is https://www.anaconda.com/.
  2. Python(x,y): It is software developed based on Python, QT (graphical user interface), and Spyder (interactive development environment). It is mainly used for engineering projects such as numerical calculation, data analysis, and data visualization. At present, it only supports Python 2 version. It is official website is https://python-xy.github.io/.
  3. WinPython: The free Python distribution includes common scientific computing packages and Spyder ide development environment, but only supports Windows. You can download it from the URL https://sourceforge.net/projects/winpython/files/.
  4. Pyzo: It is a cross-platform Python IDE, written based on Python 3. It is very suitable for scientific computing. Its official website is https://pyzo.org/.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Clicky