Como instalar o scipy e o numpy no Ubuntu 16.04?

Como instalar o scipy e o numpy no Ubuntu 16.04?

Estou tentando instalar o scipy e o numpy no Ubuntu 16.04, mas continuo recebendo o seguinte erro. Alguém pode me dizer como instalar as dependências?

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.

Responder1

Você também pode usar pip (o instalador alternativo do pacote Python) para instalar numpy e scipy para todo o sistema:

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

Isso poderia instalá-lo independentemente dos erros de dependência no gerenciador de pacotes do Ubuntu.

Responder2

Para instalar as dependências em todas as versões atualmente suportadas do Ubuntu, abra o terminal e digite os seguintes comandos:

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

Para Python 3.x

sudo apt update  
sudo apt install --no-install-recommends python3-minimal python3  
sudo apt install python3-numpy python3-scipy

Responder3

No meu caso, eu queria que o scipy fosse instalado em um ambiente virtual, em vez de globalmente. A instalação de libatlas-base-dev e gfortran antes da instalação do pip resolveu o problema:

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

informação relacionada