Installing matplotlib on Mac OS X 10.9

大憨熊 提交于 2019-12-11 13:56:04

问题


As a requirement to install OCRopus, I have successfully installed matplotlib on Mac OS X 10.9.1 by pip:

$ sudo pip install matplotlib

But after installing OCRopus the test didn't work because of laking this module: matplotlib.backends._backend_gdk. Reading this document and this question convinced me that my problems might gone if I reinstall matplotlib through:

$ sudo port install py27-matplotlib +gtk2

But on Mac OS X 10.9.1 it seems there is a bug which I receive this error: Error: Dependency 'py27-pyobjc' not found.:

--->  Computing dependencies for py27-matplotlib
Error: Dependency 'py27-pyobjc' not found.
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: Processing of port py27-matplotlib failed

All I need is to install different variant of matplotlib. This is what I get from port variants py27-matplotlib:

$ port variants py27-matplotlib
py27-matplotlib has the variants:
   cairo: Enable Cairo backends
   dvipng: Enable dvipng support
   ghostscript: Enable GhostScript support
   gtk2: Enable GTKAgg backend
   gtk3: Enable GTK3Agg backend
   latex: Enable LaTeX support
   pdftops: Enable pdftops support
   pyside: Enable PySide backend
   qt4: Enable QT4Agg backend
[+]tkinter: Enable tkAgg backend
   universal: Build for multiple architectures
   webagg: Enable WebAgg backend

Any idea how to get +gtk2 on Mac OS X 10.9.1? or how to make pip to install matplotlib with this particular settings?


回答1:


It looks like you don't have the python library for objective-C installed. Did you double-check that you installed command line tools? Then try port install py27-pyobjc

I recommend installing it via brew because I think it's better maintained, and it'll choose the best backend for you. I had a lot of issues installing matplotlib, but eventually was able to get them resolved.

Cheers, Olga




回答2:


Specifically for mac: I had a similar issue in installing the matplotlib. Follow these instructions and you are done:

  1. Open terminal.

  2. Install python3 using brew. ( Ignore this step if you already have it) Note: To install brew:

    brew install python3
    
  3. Install freetype:

    brew install freetype
    
  4. Now install pkg-config using pip3:

    brew install pkg-config
    
  5. Finally install matplotlib:

    sudo pip3 install matplotlib
    

It's late but I hope this helps you.




回答3:


It turns out problem was on my computer. I couldn't figure out the source of the problem. Finally, I tried out the process on a clean installed Mac OS X 10.9.1 with new Xcode command-line tools, and new MacPorts, and upgraded python 2.7.6, then it worked fine.



来源:https://stackoverflow.com/questions/21290751/installing-matplotlib-on-mac-os-x-10-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!