2016-05-28 24 views
1

Ich habe eine virtuelle Umgebung eingerichtet, um mit maschinellem Lernen mit pyenv herumzuspielen. Wenn ich import matplotlib.pyplot as plt laufen dieses ich, was ich bekommen:Problem beim Importieren von Matplotlib

ImportError        Traceback (most recent call last) 
<ipython-input-1-eff513f636fd> in <module>() 
----> 1 import matplotlib.pyplot as plt 

/usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>() 
    27 from cycler import cycler 
    28 import matplotlib 
---> 29 import matplotlib.colorbar 
    30 from matplotlib import style 
    31 from matplotlib import _pylab_helpers, interactive 

/usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>() 
    30 
    31 import matplotlib as mpl 
---> 32 import matplotlib.artist as martist 
    33 import matplotlib.cbook as cbook 
    34 import matplotlib.collections as collections 

/usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/artist.py in <module>() 
    12 from matplotlib.cbook import mplDeprecation 
    13 from matplotlib import docstring, rcParams 
---> 14 from .transforms import (Bbox, IdentityTransform, TransformedBbox, 
    15       TransformedPath, Transform) 
    16 from .path import Path 

/usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/transforms.py in <module>() 
    37 import numpy as np 
    38 from numpy import ma 
---> 39 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox, 
    40  update_path_extents) 
    41 from numpy.linalg import inv 

ImportError: dlopen(/usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/_path.so, 2): Symbol not found: _PyUnicodeUCS2_AsASCIIString 
    Referenced from: /usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/_path.so 
    Expected in: flat namespace 
in /usr/local/var/pyenv/versions/2.7.11/envs/machine_learning/lib/python2.7/site-packages/matplotlib/_path.so 

Ich bin auf OS X Yosemite und dies ist meine Bibliothek von Paketen, die ich über pip installiert haben:

appnope==0.1.0 
backports.shutil-get-terminal-size==1.0.0 
cffi==1.6.0 
cryptography==1.3.2 
cycler==0.10.0 
decorator==4.0.9 
enum34==1.1.6 
gnureadline==6.3.3 
idna==2.1 
inflection==0.3.1 
ipaddress==1.0.16 
ipython==4.2.0 
ipython-genutils==0.1.0 
matplotlib==1.5.1 
more-itertools==2.2 
mpmath==0.19 
ndg-httpsclient==0.4.0 
nose==1.3.7 
numpy==1.11.0 
pandas==0.18.1 
pathlib2==2.1.0 
pexpect==4.0.1 
pickleshare==0.7.2 
ptyprocess==0.5.1 
pyasn1==0.1.9 
pycparser==2.14 
pyOpenSSL==16.0.0 
pyparsing==2.1.4 
python-dateutil==2.5.3 
pytz==2016.4 
Quandl==3.0.0 
readline==6.2.4.1 
requests==2.10.0 
scikit-learn==0.17.1 
scipy==0.17.1 
simplegeneric==0.8.1 
six==1.10.0 
sympy==1.0 
traitlets==4.2.1 

Es gibt eine Lösung für die Befestigung dieses Problem?

+0

Werfen Sie einen Blick auf die erste Antwort hier: http://stackoverflow.com/questions/9386048/ipython-reads-wrong-python-version – leekaiinthesky

+0

https://trac.macports.org/ticket/43676 – dsgdfg

+0

@leekaiinthesky Ok, aber da ich in einer virtuellen Umgebung arbeite, weiß ich nicht, ob diese Lösung für mich funktioniert. Wenn ich 'which python' starte, bekomme ich'/usr/local/var/pyenv/shims/python', und running 'which ipython' holt mich'/usr/local/var/pyenv/shims/ipython'. Ist das ok? Ich kann nicht sagen, ob die Ausgabe von 'cat/usr/local/var/pyenv/shims/ipython' etwas stimmt ... –

Antwort

1

Ich habe die Lösung gefunden! Es scheint, dass die Python-Version (2.7.11), die ich in meiner virtuellen Umgebung wurde konfiguriert, um unicode=ucs4 zu verwenden, so einfach virtualenv/Python-Version zu deinstallieren und

PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install 2.7.11 

das Problem behoben läuft!

Verwandte Themen