Skip to content Skip to sidebar Skip to footer

How Do I Install Matplotlib As A Macintosh Yosemite User

I am a Macintosh Yosemite user. When I try to import matplotlib I get the following error. import matplotlib Traceback (most recent call last): File '', li

Solution 1:

Mac OS X ships with python by default. And there is one provided by homebrew. I would recommend using homebrew python over the default python.

Here, I suspect your numpy installation has landed up in the site-packages directory managed by the non-homebrew pip package manager whereas matplotlib package is installed in a different site-packages directory. (But I am not sure). Nevertheless it has something to do with multiple python's / package managers being used. This may not be the best answer, but so far the only solution I can think of to fix your problems is to uninstall pip and also remove everything in any python site-packages directory you can find on your filesystem,. And install python via homebrew again, and then install all packages required using the pip (which gets installed automatically when you install python using homebrew)

Warning: Make sure you list out the package names and store the names somewhere before deleting them because you will have to install them again.

brew uninstall python
#(ATTN) Uninstall macports and don't use it with brew#(ATTN) Delete the contents of all python site-packages directoriesrm /usr/local/lib/python2.7/site-packages/*
brew install python
# Homebrew comes with its own pip installed
pip install <package1>, <package2> ...

Here is a related question from someone who faced a similar problem: Numpy build fails with cannot import multiarray

My advice: Don't use Homebrew and Macports or any other package manager together. They mess up with each other and I have faced the consequences in the past.I just use homebrew python now. For installing scientific python packages either Anaconda or Canopy (choose one) are really helpful, which can be installed on top of the homebrew python.

Solution 2:

After having a lot of problems similar to the ones you describe, using sudo pip install -U matplotlib worked fine for me.

Post a Comment for "How Do I Install Matplotlib As A Macintosh Yosemite User"