NumPy is available in the default repositories of most popular Linux distributions and can be installed in the same way that packages in a Linux distribution are usually installed.
Some Linux distributions have different NumPy packages for Python 2.x and Python 3.x. In Ubuntu and Debian, install numpy
at the system level using the APT package manager:
sudo apt-get install python-numpy
sudo apt-get install python3-numpy
For other distributions, use their package managers, like zypper (Suse), yum (Fedora) etc.
numpy
can also be installed with Python's package manager pip
for Python 2 and with pip3
for Python 3:
pip install numpy # install numpy for Python 2
pip3 install numpy # install numpy for Python 3
pip
is available in the default repositories of most popular Linux distributions and can be installed for Python 2 and Python 3 using:
sudo apt-get install python-pip # pip for Python 2
sudo apt-get install python3-pip # pip for Python 3
After installation, use pip
for Python 2 and pip3
for Python 3 to use pip for installing Python packages.
But note that you might need to install many dependencies, which are required to build numpy from source (including development-packages, compilers, fortran etc).
Besides installing numpy
at the system level, it is also common (perhaps even highly recommended) to install numpy
in virtual environments using popular Python packages such as virtualenv
. In Ubuntu, virtualenv
can be installed using:
sudo apt-get install virtualenv
Then, create and activate a virtualenv for either Python 2 or Python 3 and then use pip
to install numpy
:
virtualenv venv # create virtualenv named venv for Python 2
virtualenv venv -p python3 # create virtualenv named venv for Python 3
source venv/bin/activate # activate virtualenv named venv
pip install numpy # use pip for Python 2 and Python 3; do not use pip3 for Python3