I'm trying to install scipy and numpy on Ubuntu 16.04 but I keep getting the following error. Can anyone tell me how to install the dependencies?

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python-numpy : Depends: python:any (>= 2.7.5-5~)
 E: Unable to correct problems, you have held broken packages.
  • Make sure your repo sources are up to date. Run the following command to fix broken or missing dependencies. sudo apt install -f Above command will only download the missing dependencies if you have already installed the package.
    – sgiri
    Jan 6, 2017 at 8:11

3 Answers 3


You can also use pip (the alternative Python package installer) to install numpy and scipy for the whole system:

sudo apt-get install python-pip  
sudo pip install numpy scipy

This could install it regardless of dependency errors in the Ubuntu package manager.

  • 1
    Would this conflict with any updates if you had already installed numpy/scipy earlier and tried using system-wide pip?
    – Ruslan
    Jun 9, 2019 at 9:13
  • If you installed them earlier with pip, then this command will not reinstall them unless you explicitly tell it to upgrade the packages.
    – don.joey
    Jun 10, 2019 at 6:42
  • 1
    I mean if you had this package installed previously.
    – Ruslan
    Jun 10, 2019 at 7:58
  • Perhaps this answer is for python2 because it didn't work for python3. karel's answer worked for python3.
    – Ramid
    Jan 6, 2021 at 11:39

To install the dependencies in all currently supported versions of Ubuntu open the terminal and type the following commands:

sudo apt update  
sudo apt install --no-install-recommends python2.7-minimal python2.7  
sudo apt install python-numpy # in Ubuntu 20.04 and earlier
sudo apt install python-scipy # in Ubuntu 18.04 and earlier

For Python 3.x

sudo apt update  
sudo apt install --no-install-recommends python3-minimal python3  
sudo apt install python3-numpy python3-scipy
  • I'm still getting the same error.
    – Rahul
    Jan 6, 2017 at 10:18
  • python --version gives Python 2.7.12
    – Rahul
    Jan 6, 2017 at 10:20
  • python-numpy : Depends: python:any (>= 2.7.5-5~)is the error message in your question. You have a more recent version of Python 2.7.12 installed, however you are still getting the same error anyway.
    – karel
    Jan 6, 2017 at 10:28
  • This is the real answer. Always use apt (the same as apt-get) if you can, it will not lead to conflicts, while pip will sometimes disturb your dependencies and versions. Mar 18, 2021 at 21:48

In my case I wanted scipy installed into a virtual environment instead of globally. Installing libatlas-base-dev and gfortran prior to pip install resolved the issue:

sudo apt-get install libatlas-base-dev
sudo apt-get install gfortran
source .venv/bin/activate
pip install scipy

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .