Wie installiere ich Scipy und Numpy auf Ubuntu 16.04?

Wie installiere ich Scipy und Numpy auf Ubuntu 16.04?

Ich versuche, Scipy und Numpy auf Ubuntu 16.04 zu installieren, erhalte aber immer wieder den folgenden Fehler. Kann mir jemand sagen, wie ich die Abhängigkeiten installiere?

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.

Antwort1

Sie können auch pip (das alternative Python-Paketinstallationsprogramm) verwenden, um Numpy und Scipy für das gesamte System zu installieren:

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

Dadurch könnte es unabhängig von Abhängigkeitsfehlern im Ubuntu-Paketmanager installiert werden.

Antwort2

Um die Abhängigkeiten in allen derzeit unterstützten Versionen von Ubuntu zu installieren, öffnen Sie das Terminal und geben Sie die folgenden Befehle ein:

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

Für Python 3.x

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

Antwort3

In meinem Fall wollte ich Scipy in einer virtuellen Umgebung statt global installieren. Die Installation von libatlas-base-dev und gfortran vor der Pip-Installation löste das Problem:

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

verwandte Informationen