How to Install NumPy

Posted on

Introduction

In this article, the main focus exist as it is in the title of the article. It is focusing on how to install a modul library with the name of ‘NumPy’. It is an important package for manipulating data. Basically, ‘NumPy’ is a a library for Python that adds support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. Moreover, utilizing the NumPy package, Pandas library is built as a high-level data manipulation tool.

How to Install NumPy

Basically, in order to install NumPy, the following is a normal steps or sequence to achieve it :

  1. First of all, run the Command Prompt. In this example, it is using a device running Microsoft Windows operating system. Just choose any available command console to start the installation process.

  2. After the Command Prompt appears, just run the following command to check whether ‘pip’ tool is available or not. It is important to have ‘pip’ tool because the installation of ‘numpy’ will need ‘pip’ tool. Just type ‘pip’ in the Command Prompt as follows :

    C:\Users\Personal>pip
    Usage:
    pip <command> [options]
    Commands:
    install Install packages.
    download Download packages.
    uninstall Uninstall packages.
    freeze Output installed packages in requirements format.
    list List installed packages.
    show Show information about installed packages.
    check Verify installed packages have compatible dependencies.
    config Manage local and global configuration.
    search Search PyPI for packages.
    cache Inspect and manage pip's wheel cache.
    index Inspect information available from package indexes.
    wheel Build wheels from your requirements.
    hash Compute hashes of package archives.
    completion A helper command used for command completion.
    debug Show information useful for debugging.
    help Show help for commands.
    General Options:
    -h, --help Show help.
    --debug Let unhandled exceptions propagate outside the main subroutine, instead of logging them
    to stderr.
    --isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
    --require-virtualenv Allow pip to only run in a virtual environment; exit with an error otherwise.
    -v, --verbose Give more output. Option is additive, and can be used up to 3 times.
    -V, --version Show version and exit.
    -q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to
    WARNING, ERROR, and CRITICAL logging levels).
    --log <path> Path to a verbose appending log.
    --no-input Disable prompting for input.
    --proxy <proxy> Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.
    --retries <retries> Maximum number of retries each connection should attempt (default 5 times).
    --timeout <sec> Set the socket timeout (default 15 seconds).
    --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
    (a)bort.
    --trusted-host <hostname> Mark this host or host:port pair as trusted, even though it does not have valid or any
    HTTPS.
    --cert <path> Path to PEM-encoded CA certificate bundle. If provided, overrides the default. See 'SSL
    Certificate Verification' in pip documentation for more information.
    --client-cert <path> Path to SSL client certificate, a single file containing the private key and the
    certificate in PEM format.
    --cache-dir <dir> Store the cache data in <dir>.
    --no-cache-dir Disable the cache.
    --disable-pip-version-check
    Don't periodically check PyPI to determine whether a new version of pip is available for
    download. Implied with --no-index.
    --no-color Suppress colored output.
    --no-python-version-warning
    Silence deprecation warnings for upcoming unsupported Pythons.
    --use-feature <feature> Enable new functionality, that may be backward incompatible.
    --use-deprecated <feature> Enable deprecated functionality, that will be removed in the future.
    C:\Users\Personal>
    

    Furthermore, if there is no ‘pip’ tool exist currently, just check the article with the title of ‘How to Install pip in Microsoft Windows’ in this link as a reference. Another article with the title of ‘How to Install pip in Microsoft Windows 11’ in this link can also be useful as a reference.

  3. After checking the existence of ‘pip’ tool, just check the existence of the NumPy library itself. In order to do that, just list the available module library or package in the device. Just execute the following command :

    C:\Users\Personal>pip freeze
    appdirs==1.4.4
    beautifulsoup4==4.11.1
    bs4==0.0.1
    CacheControl==0.12.6
    certifi==2021.10.8
    chardet==4.0.0
    commonmark==0.9.1
    coverage==6.2
    distlib==0.3.4
    filelock==3.7.1
    idna==3.3
    lockfile==0.12.2
    lxml==4.7.1
    msgpack==1.0.3
    Pillow==9.0.1
    pip-search==0.0.12
    platformdirs==2.5.2
    pycairo==1.20.1
    Pygments==2.12.0
    PyGObject==3.40.1
    pyserial==3.5
    requests==2.25.1
    rich==12.4.4
    scour==0.38.2
    six==1.16.0
    soupsieve==2.3.2.post1
    style==1.1.0
    tzdata==2022.1
    update==0.0.1
    urllib3==1.26.8
    virtualenv==20.14.1
    C:\Users\Personal>

    As for further understanding on the above execution for listing available module, package library, just read an article with the title of ‘How to List Installed Packages and Version using pip tool’ in this link.

  4. Apparently, in the output above, there is no ‘NumPy’ library package exist. So, in order to install it, check the availability of the ‘NumPy’ library package first. It is important to check if it is possible for further download and installation. Below is the example of the command execution to achieve it :

    C:\Users\Personal>python -m pip_search numpy
    🐍 https://pypi.org/search/?q=numpy 🐍
    ┌──────────────────────┬───────────┬────────────┬───────────────────────────────────────────────────────────────────┐
      Package                Version     Released                    Description
    ├──────────────────────┼───────────┼────────────┼───────────────────────────────────────────────────────────────────┤
    │ 📂 numpy              1.23.2 ==   14-08-2022   NumPy is the fundamental package for array computing with Python.
    │ 📂 numpy1             0.0.1       24-01-2021   Python
      ...
    └──────────────────────┴───────────┴────────────┴───────────────────────────────────────────────────────────────────┘
    C:\Users\Personal>
    

    For an additional reference on how to search package or module library just read the article with the title of ‘How to Search Package, Module or Library Python using pip_search’ in this link.

  5. Fortunately, it is clearly in the above output is showing a module package or library exist with the name of ‘NumPy’. Therefore, just execute the following command to install the ‘NumPy’ module package or library :

    C:\Users\Personal>pip install numpy
    Collecting numpy
    Using cached numpy-1.23.2-cp310-cp310-win_amd64.whl (14.6 MB)
    Installing collected packages: numpy
    Successfully installed numpy-1.23.2
    WARNING: You are using pip version 22.0.4; however, version 22.2.2 is available.
    You should consider upgrading via the 'C:\python\python310\python.exe -m pip install --upgrade pip' command.
    C:\Users\Personal>
    

Actually, there is another simply way for installing NumPy library. Just install Pandas library in the first place. It will automatically install NumPy as it exist in this article with the title of ‘How to Install Pandas’ in this link. It is obvious it will install NumPy package before installing Pandas library. The reason is because Pandas library is built utilizing NumPy library as one of the feature for a high-level data manipulation tool.

Leave a Reply