2016-06-07 10 views
0

Ich bekomme einen ImportError, wenn ich versuche, pyplot aus Matplotlib zu importieren. Matplotlib wird via Pip in einer virtuellen Umgebung installiert. Das ist der Fehler, den ich erhalte:ImportError libqhull.so.5 beim Import von pyplot

>>> import matplotlib.pyplot 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 36, in <module> 
from matplotlib.figure import Figure, figaspect 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/figure.py", line 40, in <module> 
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/axes/__init__.py", line 4, in <module> 
from ._subplots import * 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py", line 10, in <module> 
from matplotlib.axes._axes import Axes 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 38, in <module> 
import matplotlib.tri as mtri 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/tri/__init__.py", line 9, in <module> 
from .triangulation import * 
    File "/home/mikefrank/.virtualenvs/pv-hrt/local/lib/python2.7/site-packages/matplotlib/tri/triangulation.py", line 7, in <module> 
import matplotlib._qhull as _qhull 
ImportError: libqhull.so.5: cannot open shared object file: No such file or directory 
+0

haben Sie bereits versucht, matplotlib erneut zu installieren? – cel

+0

Ja, ich habe versucht, es über pip und apt-get neu zu installieren. – amalik

+0

»» libqhull.so.5: Keine solche Datei oder Verzeichnis ««: Bitte installieren Sie "libqhull5", falls verfügbar. Qhull-2003.1 (.tar.gz) liefert 'libqhull.so.5' - –

Antwort

3

Dies kann nach einem Systemupgrade auftreten. In meinem speziellen Fall habe ich Ubuntu 14.04 auf 16.04 aktualisiert. Matplotlib verweist auf bestimmte Versionen von \*.so, die veraltet sind. Ich gehe davon aus, dass die verschiedenen Versionen nicht (immer) abwärtskompatibel sind. (Für mich ging ich libqhull.so.6-libqhull.so.7 während des OS-Upgrade, und matplotlib wurde libqhull.so.6 verknüpft.)

Zum einen können Sie wahrscheinlich sicherstellen, dass libqhull auf Ihrem System vorhanden ist, indem Sie so etwas wie:

sudo apt install libqhull-dev 

oder das Äquivalent für Ihr System. (Mine wurde bereits installiert, also nichts geändert.)

Seit heute installiert pip oft ein Rad, das bereits kompiliert wird, werden wir pip zwingen müssen, um die Kompilierung zu tun, so ist es mit der neuen so Datei . I verwendet:

py35 -m pip install --upgrade matplotlib --no-binary matplotlib --force 

Die Optionen:

  • --no-binary matplotlib sagt pip kein Rad für matplotlib zu verwenden (aber es kann immer noch Räder für Abhängigkeiten verwenden wie numpy).
  • --upgrade sollte
  • --force, offensichtlich, weil wir schon bei der neuesten Version matplotlib sein können, und --upgrade wird dann nichts tun.