How to Install NumPy with Python

Hello All, I am new in this community and I don’t know how to install NumPy with python distribution. I am using windows and already install package manager but I don’t know the proper step bt step installation process. Can anyone tell me how to install it?

You need to provide more details of your python version, and whether you installed Python using “Administrator” privileges. You should consult the documentation for your Python installation, but I’ll provide an example for a common “use case” of a Python.org non-Admin installation below.

I’m not sure which “package manager” you mean. Also, Windows systems often have multiple python installations, so care is needed to ensure you are using the one you want for ESA SNAP snappy. If you have an Anaconda or miniconda Python you should use conda to install numpy. Use py -0 to get a list of the Python installs known to Windows, e.g.:

PS C:\> py -0
Installed Pythons found by C:\WINDOWS\py.exe Launcher for Windows
 -3.9-64 *
 -3.8-64
 -3.7-64
 -3.6-64

I use Python 3.6 for ESA SNAP snappy, so

PS C:\> cd $env:USERPROFILE\.snap\snap-python\
PS C:\Users\XXXXX\.snap\snap-python> py -3.6
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import snappy
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL not found on system. Internal GDAL 3.0.0 from distribution will be used. (f1)
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Internal GDAL 3.0.0 set to be used by SNAP.
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
>>>

This is a Python.org version. An [Ana]conda Python install mentions that when you run Python using the command-line.

(base) PS C:\> Python
Python 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 22:54:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

To install numpy on a Python.org version for use with snappy:

PS C:\> py -3.6 -m pip install numpy
Collecting numpy
  Downloading https://files.pythonhosted.org/packages/ea/bc/da526221bc111857c7ef39c3af670bbcf5e69c247b0d22e51986f6d0c5c2/numpy-1.19.5-cp36-cp36m-win_amd64.whl (13.2MB)
    100% |████████████████████████████████| 13.2MB 3.9MB/s
Installing collected packages: numpy
  The script f2py.exe is installed in 'D:\Python36\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.19.5
You are using pip version 18.1, however version 21.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Note that using py -M.N doesn’t adjust the PATH to include the Scripts
directory (there is also a directory for Python scripts in the user’s AppData (hidden) folder that is used for installations when Python was installed by “Admin” and a user needs to install a package without Admin
privileges.

2 Likes

Thanks, it is very useful to me. I have checked this post as well where I have found some step like:

PC easily installs NumPy by following these simple steps:

With Python Wheels:

  1. You require Python on your system.
  2. If you are using Windows, add Python to the PATH environment variable.
  3. Install a package manager, such as pip (done to ensure that you can use Python’s open-source libraries.
  4. Download (NumPy Wheel) and navigate through to the folder (on your PC) that stores it.

Those “easy” steps don’t take ESA SNAP snappy into account, and have several inaccuracies:

Step 2) For Windows, Python needs 3 directories. Failure to include
the 2 Scripts directories may explain why the author thought Step 3
was necessary.

Step 3. most Python installs include the pip package manager. It
is recommended that you not call pip directly but use python -m pip ....

Step 4. There are many different NumPy wheels: multiple numpy versions, different compilers using different runtime libraries, and different
python versions. If you use the python -m pip ... it will generally choose an appropriate binary wheel.

NumPy is a popular library for numerical computing in Python. It provides a high-performance multidimensional array object and tools for working with these arrays. Here’s how you can install NumPy with Python:

  1. Open the Command Prompt (Windows) or Terminal (Mac/Linux).
  2. Type the following command and press enter:
pip install numpy

This command will install NumPy and its dependencies. Once the installation is complete, you can start using NumPy in your Python projects.

If you encounter any errors or issues during the installation process, you can check the NumPy installation guide on the official website for more information.

It’s also worth mentioning that understanding and using NumPy is just one of the many skills you’ll learn in A2N’s Python Course Online. Our comprehensive course covers all aspects of Python programming, from the basics to advanced topics, and provides hands-on experience with real-world projects.

To install NumPy using pip, open your terminal or command prompt and type the following command:

pip install numpy

This will download and install the latest version of NumPy and its dependencies. To verify that the installation was successful, start a Python interpreter or a script and import the NumPy module:

import numpy as np

If the import statement runs without raising any errors, NumPy is successfully installed and ready to use.