Reputation: 79
I am trying to import Pylab using the import matplotlib.pyplot as plt
. However I received an error message below. Does anyone have a fix for this? I'm using Enthought's distribution, which uses IPython 0.12.
In [1]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt
/Library/Python/2.7/site-packages/matplotlib/pyplot.py in <module>()
21 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
22 from matplotlib import docstring
---> 23 from matplotlib.figure import Figure, figaspect
24 from matplotlib.backend_bases import FigureCanvasBase
25 from matplotlib.image import imread as _imread
/Library/Python/2.7/site-packages/matplotlib/figure.py in <module>()
16 import artist
17 from artist import Artist, allow_rasterization
---> 18 from axes import Axes, SubplotBase, subplot_class_factory
19 from cbook import flatten, allequal, Stack, iterable, is_string_like
20 import _image
/Library/Python/2.7/site-packages/matplotlib/axes.py in <module>()
12 import matplotlib.artist as martist
13 from matplotlib.artist import allow_rasterization
---> 14 import matplotlib.axis as maxis
15 import matplotlib.cbook as cbook
16 import matplotlib.collections as mcoll
/Library/Python/2.7/site-packages/matplotlib/axis.py in <module>()
8 from matplotlib.artist import allow_rasterization
9 import matplotlib.cbook as cbook
---> 10 import matplotlib.font_manager as font_manager
11 import matplotlib.lines as mlines
12 import matplotlib.patches as mpatches
/Library/Python/2.7/site-packages/matplotlib/font_manager.py in <module>()
50 import matplotlib
51 from matplotlib import afm
---> 52 from matplotlib import ft2font
53 from matplotlib import rcParams, get_configdir
54 from matplotlib.cbook import is_string_like
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib/ft2font.so, 2): Library not loaded: /opt/local/lib/libfreetype.6.dylib
Referenced from: /Library/Python/2.7/site-packages/matplotlib/ft2font.so
Reason: image not found
Edit: The output of ls -ltr /Library/Python/2.7/site-packages/matplotlib/
:
total 19800
-rw-r--r-- 1 root wheel 44538 Sep 24 21:21 widgets.py
-rw-r--r-- 1 root wheel 5035 Sep 24 21:21 units.py
-rw-r--r-- 1 root wheel 11537 Sep 24 21:21 type1font.py
-rw-r--r-- 1 root wheel 77154 Sep 24 21:21 transforms.py
-rw-r--r-- 1 root wheel 7098 Sep 24 21:21 tight_layout.py
-rw-r--r-- 1 root wheel 3839 Sep 24 21:21 tight_bbox.py
-rw-r--r-- 1 root wheel 51195 Sep 24 21:21 ticker.py
-rw-r--r-- 1 root wheel 15516 Sep 24 21:21 textpath.py
-rw-r--r-- 1 root wheel 69526 Sep 24 21:21 text.py
-rw-r--r-- 1 root wheel 22703 Sep 24 21:21 texmanager.py
-rw-r--r-- 1 root wheel 16868 Sep 24 21:21 table.py
-rw-r--r-- 1 root wheel 17723 Sep 24 21:21 spines.py
-rw-r--r-- 1 root wheel 14316 Sep 24 21:21 scale.py
-rw-r--r-- 1 root wheel 40573 Sep 24 21:21 sankey.py
-rw-r--r-- 1 root wheel 25707 Sep 24 21:21 rcsetup.py
-rw-r--r-- 1 root wheel 40599 Sep 24 21:21 quiver.py
-rw-r--r-- 1 root wheel 92531 Sep 24 21:21 pyplot.py
-rw-r--r-- 1 root wheel 143924 Sep 24 21:21 pyparsing.py
-rw-r--r-- 1 root wheel 11742 Sep 24 21:21 pylab.py
-rw-r--r-- 1 root wheel 6826 Sep 24 21:21 patheffects.py
-rw-r--r-- 1 root wheel 24453 Sep 24 21:21 path.py
-rw-r--r-- 1 root wheel 133545 Sep 24 21:21 patches.py
-rw-r--r-- 1 root wheel 50156 Sep 24 21:21 offsetbox.py
-rw-r--r-- 1 root wheel 785 Sep 24 21:21 mpl.py
-rw-r--r-- 1 root wheel 100604 Sep 24 21:21 mlab.py
-rw-r--r-- 1 root wheel 109731 Sep 24 21:21 mathtext.py
-rw-r--r-- 1 root wheel 23594 Sep 24 21:21 markers.py
-rw-r--r-- 1 root wheel 38180 Sep 24 21:21 lines.py
-rw-r--r-- 1 root wheel 20098 Sep 24 21:21 legend_handler.py
-rw-r--r-- 1 root wheel 35251 Sep 24 21:21 legend.py
-rw-r--r-- 1 root wheel 46614 Sep 24 21:21 image.py
-rw-r--r-- 1 root wheel 6564 Sep 24 21:21 hatch.py
-rw-r--r-- 1 root wheel 16092 Sep 24 21:21 gridspec.py
-rw-r--r-- 1 root wheel 6429 Sep 24 21:21 fontconfig_pattern.py
-rw-r--r-- 1 root wheel 43749 Sep 24 21:21 font_manager.py
-rw-r--r-- 1 root wheel 23033 Sep 24 21:21 finance.py
-rw-r--r-- 1 root wheel 50232 Sep 24 21:21 figure.py
-rw-r--r-- 1 root wheel 32575 Sep 24 21:21 dviread.py
-rw-r--r-- 1 root wheel 3769 Sep 24 21:21 docstring.py
-rw-r--r-- 1 root wheel 40070 Sep 24 21:21 dates.py
-rw-r--r-- 1 root wheel 54477 Sep 24 21:21 contour.py
-rw-r--r-- 1 root wheel 2832 Sep 24 21:21 container.py
-rw-r--r-- 1 root wheel 44186 Sep 24 21:21 colors.py
-rw-r--r-- 1 root wheel 34547 Sep 24 21:21 colorbar.py
-rw-r--r-- 1 root wheel 45282 Sep 24 21:21 collections.py
-rw-r--r-- 1 root wheel 9508 Sep 24 21:21 cm.py
-rw-r--r-- 1 root wheel 59573 Sep 24 21:21 cbook.py
-rw-r--r-- 1 root wheel 12895 Sep 24 21:21 blocking_input.py
-rw-r--r-- 1 root wheel 16237 Sep 24 21:21 bezier.py
-rw-r--r-- 1 root wheel 94652 Sep 24 21:21 backend_bases.py
-rw-r--r-- 1 root wheel 72371 Sep 24 21:21 axis.py
-rw-r--r-- 1 root wheel 301792 Sep 24 21:21 axes.py
-rw-r--r-- 1 root wheel 37279 Sep 24 21:21 artist.py
-rw-r--r-- 1 root wheel 19948 Sep 24 21:21 animation.py
-rw-r--r-- 1 root wheel 15422 Sep 24 21:21 afm.py
-rw-r--r-- 1 root wheel 3275 Sep 24 21:21 _pylab_helpers.py
-rw-r--r-- 1 root wheel 89917 Sep 24 21:21 _mathtext_data.py
-rw-r--r-- 1 root wheel 88432 Sep 24 21:21 _cm.py
-rw-r--r-- 1 root wheel 33452 Sep 24 21:21 __init__.py
-rwxr-xr-x 1 root wheel 844488 Sep 24 21:21 ft2font.so
-rwxr-xr-x 1 root wheel 152904 Sep 24 21:21 ttconv.so
-rwxr-xr-x 1 root wheel 53672 Sep 24 21:21 _cntr.so
-rwxr-xr-x 1 root wheel 35020 Sep 24 21:21 nxutils.so
-rwxr-xr-x 1 root wheel 161740 Sep 24 21:21 _delaunay.so
-rwxr-xr-x 1 root wheel 741008 Sep 24 21:21 _path.so
-rwxr-xr-x 1 root wheel 693588 Sep 24 21:21 _tri.so
-rwxr-xr-x 1 scott wheel 828348 Sep 24 21:21 _image.so copy
-rwxr-xr-x 1 root wheel 828348 Sep 24 21:21 _image.so
-rwxr-xr-x 1 root wheel 488096 Sep 24 21:22 _png.so
drwxr-xr-x 7 root wheel 238 Sep 24 21:22 mpl-data
-rw-r--r-- 1 root wheel 44944 Sep 24 21:22 widgets.pyc
-rw-r--r-- 1 root wheel 5808 Sep 24 21:22 units.pyc
-rw-r--r-- 1 root wheel 11090 Sep 24 21:22 type1font.pyc
drwxr-xr-x 12 root wheel 408 Sep 24 21:22 tri
-rw-r--r-- 1 root wheel 91307 Sep 24 21:22 transforms.pyc
-rw-r--r-- 1 root wheel 6061 Sep 24 21:22 tight_layout.pyc
-rw-r--r-- 1 root wheel 4172 Sep 24 21:22 tight_bbox.pyc
-rw-r--r-- 1 root wheel 57906 Sep 24 21:22 ticker.pyc
-rw-r--r-- 1 root wheel 14645 Sep 24 21:22 textpath.pyc
-rw-r--r-- 1 root wheel 67364 Sep 24 21:22 text.pyc
-rw-r--r-- 1 root wheel 19813 Sep 24 21:22 texmanager.pyc
drwxr-xr-x 50 root wheel 1700 Sep 24 21:22 tests
drwxr-xr-x 11 root wheel 374 Sep 24 21:22 testing
-rw-r--r-- 1 root wheel 16758 Sep 24 21:22 table.pyc
-rw-r--r-- 1 root wheel 15471 Sep 24 21:22 spines.pyc
drwxr-xr-x 12 root wheel 408 Sep 24 21:22 sphinxext
-rw-r--r-- 1 root wheel 19505 Sep 24 21:22 scale.pyc
-rw-r--r-- 1 root wheel 26862 Sep 24 21:22 sankey.pyc
-rw-r--r-- 1 root wheel 22428 Sep 24 21:22 rcsetup.pyc
-rw-r--r-- 1 root wheel 35530 Sep 24 21:22 quiver.pyc
-rw-r--r-- 1 root wheel 91567 Sep 24 21:22 pyplot.pyc
-rw-r--r-- 1 root wheel 144868 Sep 24 21:22 pyparsing.pyc
-rw-r--r-- 1 root wheel 13151 Sep 24 21:22 pylab.pyc
drwxr-xr-x 8 root wheel 272 Sep 24 21:22 projections
-rw-r--r-- 1 root wheel 7714 Sep 24 21:22 patheffects.pyc
-rw-r--r-- 1 root wheel 22967 Sep 24 21:22 path.pyc
-rw-r--r-- 1 root wheel 134328 Sep 24 21:22 patches.pyc
-rw-r--r-- 1 root wheel 54567 Sep 24 21:22 offsetbox.pyc
-rw-r--r-- 1 root wheel 1175 Sep 24 21:22 mpl.pyc
-rw-r--r-- 1 root wheel 105969 Sep 24 21:22 mlab.pyc
-rw-r--r-- 1 root wheel 109167 Sep 24 21:22 mathtext.pyc
-rw-r--r-- 1 root wheel 25276 Sep 24 21:22 markers.pyc
-rw-r--r-- 1 root wheel 41185 Sep 24 21:22 lines.pyc
-rw-r--r-- 1 root wheel 18782 Sep 24 21:22 legend_handler.pyc
-rw-r--r-- 1 root wheel 28941 Sep 24 21:22 legend.pyc
-rw-r--r-- 1 root wheel 44466 Sep 24 21:22 image.pyc
-rw-r--r-- 1 root wheel 9038 Sep 24 21:22 hatch.pyc
-rw-r--r-- 1 root wheel 14893 Sep 24 21:22 gridspec.pyc
-rw-r--r-- 1 root wheel 6491 Sep 24 21:22 fontconfig_pattern.pyc
-rw-r--r-- 1 root wheel 40188 Sep 24 21:22 font_manager.pyc
-rw-r--r-- 1 root wheel 19865 Sep 24 21:22 finance.pyc
-rw-r--r-- 1 root wheel 51123 Sep 24 21:22 figure.pyc
-rw-r--r-- 1 root wheel 33935 Sep 24 21:22 dviread.pyc
-rw-r--r-- 1 root wheel 5278 Sep 24 21:22 docstring.pyc
drwxr-xr-x 10 root wheel 340 Sep 24 21:22 delaunay
-rw-r--r-- 1 root wheel 43998 Sep 24 21:22 dates.pyc
-rw-r--r-- 1 root wheel 46848 Sep 24 21:22 contour.pyc
-rw-r--r-- 1 root wheel 4997 Sep 24 21:22 container.pyc
-rw-r--r-- 1 root wheel 43736 Sep 24 21:22 colors.pyc
-rw-r--r-- 1 root wheel 32285 Sep 24 21:22 colorbar.pyc
-rw-r--r-- 1 root wheel 46694 Sep 24 21:22 collections.pyc
-rw-r--r-- 1 root wheel 10966 Sep 24 21:22 cm.pyc
-rw-r--r-- 1 root wheel 71936 Sep 24 21:22 cbook.pyc
-rw-r--r-- 1 root wheel 14396 Sep 24 21:22 blocking_input.pyc
-rw-r--r-- 1 root wheel 14524 Sep 24 21:22 bezier.pyc
drwxr-xr-x 59 root wheel 2006 Sep 24 21:22 backends
-rw-r--r-- 1 root wheel 98700 Sep 24 21:22 backend_bases.pyc
-rw-r--r-- 1 root wheel 68984 Sep 24 21:22 axis.pyc
-rw-r--r-- 1 root wheel 268555 Sep 24 21:22 axes.pyc
-rw-r--r-- 1 root wheel 40988 Sep 24 21:22 artist.pyc
-rw-r--r-- 1 root wheel 15092 Sep 24 21:22 animation.pyc
-rw-r--r-- 1 root wheel 16956 Sep 24 21:22 afm.pyc
-rw-r--r-- 1 root wheel 4467 Sep 24 21:22 _pylab_helpers.pyc
-rw-r--r-- 1 root wheel 64647 Sep 24 21:22 _mathtext_data.pyc
-rw-r--r-- 1 root wheel 81690 Sep 24 21:22 _cm.pyc
-rw-r--r-- 1 root wheel 32767 Sep 24 21:22 __init__.pyc
And the output of ls -ltr /opt/local/lib/
:
ls: /opt/local/lib/: No such file or directory
Upvotes: 0
Views: 3507
Reputation: 108
You're importing the from the system Python's site-packages directory (/Library/Python/2.7/site-packages) rather than EPD's site-packages directory (/Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages).
This is likely due to .pth files in your system site-packages directory. Those files are causing the system site-packages directory to get added to your PYTHONPATH when running EPD's Python (look at sys.path to confirm) Delete or otherwise remove those files and you should be able to import from the matplotlib that comes with EPD.
Upvotes: 1
Reputation: 21839
Try removing your font caches and trying again:
rm -rf ~/.matplotlib/*cache*
Alternatively, would you be able to provide the output of
ls -ltr /Library/Python/2.7/site-packages/matplotlib/
and
/opt/local/lib/
Upvotes: 0