Install MatPlotLib 1.2.x on OS X Lion 10.7.4 and Python 3.2.2

柔情痞子 提交于 2019-12-02 05:44:34
Adam McNicol

Okay...I think have managed to get matplotlib to install now...

  1. First of all you need to install numpy. I have instructions to do this on another post: install numpy

  2. Now open Terminal and clone the git repository for matplotlib (assumes you have git installed):

    • git clone git://github.com/matplotlib/matplotlib.git (this might take a while)
  3. Once the clone is complete open your user folder in Finder

  4. In your user folder open the matplotlib directory

  5. There is a file called `make.osx' open this with TextEdit (or similar)

  6. Change the following lines:

    • MACOSX_DEPLOYMENT_TARGET=10.6
    • OSX_SDK_VER=10.6

    To:

    • MACOSX_DEPLOYMENT_TARGET=10.7
    • OSX_SDK_VER=10.7
  7. Change the following lines:

    • ${PYTHON} -c 'import urllib; urllib.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'

    To:

    • ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\ ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\ ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'
  8. Save the changes

  9. Open the file called setupext.py in idle

  10. Find the line 'darwin' : [], and change it to 'darwin' : ['/usr/local'],

  11. Save the file

  12. Open Terminal again and type the following:

    • sudo make -f make.osx PREFIX=/usr/local PYVERSION=3.2 fetch deps mpl_build mpl_install
  13. After some time matplotlib should be installed in the following directory:

    • /usr/local/lib/Python3.2/site-packages/
  14. Open the above directory and also the following directory:

    • /Library/Python/3.2/site-packages/
  15. Copy/move the following directories from /usr/local/lib/Python3.2/site-packages/ to /Library/Python/3.2/site-packages/:

    • dateutil
    • matplotlib
    • mpl_toolkits
  16. matplotlib should be now installed

  17. If you open idle and type import matplotlib it shouldn't return an error

  18. I tried out the matplotlib/examples/user_interfaces/embedding_in_qt4_wtoolbar.py file and it seems works fine

Hope someone else finds this useful!

Thanks again for the assistance,

Adam.

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