The two main tools that install Python packages are
pip
and
conda
. Their functionality partially overlaps (e.g. both can install
numpy
), however, they can also work together. We’ll discuss the major differences between pip and conda here - this is important to understand if you want to manage packages effectively.
The first difference is that conda is cross-language and it can install Python, while pip is installed for a particular Python on your system and installs other packages to that same Python install only. This also means conda can install non-Python libraries and tools you may need (e.g. compilers, CUDA, HDF5), while pip can’t.
The second difference is that pip installs from the Python Packaging Index (PyPI), while conda installs from its own channels (typically “defaults” or “conda-forge”). PyPI is the largest collection of packages by far, however, all popular packages are available for conda as well.
The third difference is that conda is an integrated solution for managing packages, dependencies and environments, while with pip you may need another tool (there are many!) for dealing with environments or complex dependencies.
-
Conda:
If you use conda, you can install NumPy from the defaults or conda-forge channels:
conda create -n my-env
conda activate my-env
conda install numpy
-
Pip:
Tip
Tip:
Use a virtual environment for better dependency management
python -m venv my-env
source my-env/bin/activate # macOS/Linux
my-env\Scripts\activate # Windows
pip install numpy
For advanced users and developers who want to customize or debug
NumPy
.
A word of warning: building Numpy from source can be a nontrivial exercise.
We recommend using binaries instead if those are available for your platform via one of the above methods.
For details on how to build from source, see
the building from source guide in the Numpy docs
.