42

Having my system prepped with homebrew and using pip install matplotlib after successful installation of numpy and scipy, I'm getting a successful installation. Then, running

$ python
Python 2.7.6 (default, Jan 30 2014, 20:19:23) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'1.1.1'

This is a very outdated version and noone of my programs run with it. I used pip uninstall matplotlib and redid it with pip install 'the url for 1.3.1' and it still reads version 1.1.1. Is there a way I can manually delete all python libraries, even python itself, and restart from scratch? Or is this an obvious fix for this?

EDIT: I'm running Mac OS X version 10.9. I just reinstalled python 2.7 with scipy, numpy, and matplotlib through macports. Is there a very basic way to see where, when I import matplotlib from the python environment, it is calling it from? Like which in the terminal? I began using homebrew but switched to macports for more control. Can that be a problem? Do I need to completely remove homebrew?

I did get this message at first: Warning: Error parsing file /Applications/MacPorts/Python 2.7/Python Launcher.app/Contents/MacOS/Python Launcher: Error opening or reading file but after running $ sudo port -f deactivate python27 followed by sudo port activate python27 I no longer have that warning, but I wanted to include this detail for completeness.

EDIT 2: Could some things be installing to opt/local/bin when they need to be installed to usr/local/bin?

EDIT 3: To shed some light on this, print scipy.__version__ reads 0.11.0 which is several outdated, print numpy.__version__ reads 1.6.2 which is also outdated. However I attempt to install says the installation was successful, which I don't doubt. I suspect it's not linked up together in a correct way. Is there a way delete everything that is connected to python at all and restart?

FINAL EDIT: I think the easiest way to handle this is to run which python and see what options you have to run python. Because I used homebrew and macports at this time (not recommended) I had four options- a macports install, a package install from python.org, a homebrew install, and the standard 2.6 from Apple. Iterate through these and find which one your installer (pip or easy_install) is placing your frameworks and run that python when you need certain dependencies. The best way is use only one package manager and run virtual environments if you need different dependencies, but we're all learning as we go.

4
  • 1
    Are you using Mac OSX? Commented Jan 31, 2014 at 9:05
  • 1
    which version of pip do you have? Commented Jan 31, 2014 at 12:04
  • pip 1.4.1 is my current version running on Mac OSX 10.9 Commented Feb 5, 2014 at 1:10
  • You may want to use Scipy Superpack to install your matplotlib, numpy, and scipy on OS X. It is a quick and easy way to ensure that you have recent 64-bit builds of these packages. You can find it on github here: github.com/fonnesbeck/ScipySuperpack Commented Feb 11, 2014 at 14:42

5 Answers 5

61

Copy-Paste the following code in your terminal and press enter , it will show the version of matplotlib installed on your system ::

python 
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))
Sign up to request clarification or add additional context in comments.

3 Comments

(Or more succinctly: python -c "import matplotlib; print('matplotlib: {}'.format(matplotlib.__version__))"
This command does not work anymore.
@AsifMehmood the code works in the terminal but not in the script itself.
2
+50

Using Matplotlib in OSX can give you problems. In this page, they say:

The build situation on OSX is complicated by the various places one can get the libpng and freetype requirements (darwinports, fink, /usr/X11R6) and the different architectures (e.g., x86, ppc, universal) and the different OSX version (e.g., 10.4 and 10.5).

In the official page of Matplotlib they recommend to use the mkpg installer:

The mkpg installer will have a “zip” extension, and will have a name like matplotlib-1.2.0-py2.7-macosx10.5_mpkg.zip. The name of the installer depends on which versions of python, matplotlib, and OSX it was built for. [...] install to a directory like /Library/Python/2.7/site-packages/ (exact path depends on your python version).

In the OSX-Notes Section you have more information about this installing.

Edited:

I haven't found any MPKG but you can use this DMG.

2 Comments

in /Library/Python/2.7/site-packages/ has no mention of matplotlib now after installing. Which file should be present there? A matplolib*.egg of some kind?
It should be present a matplotlib folder
1

The problem was with the $PATH variable. Instead of changing something in that variable, I uninstalled all packages in ./Library/Frameworks/. Either way would work. When I was getting that my current version was '1.1.1', that was the current version for the standard python installed on Mac, which is version 2.6, when I was updating with all of the current libraries for 2.7.

NOTE: When uninstalling the frameworks, do not uninstall 2.6 however because the preinstalled mac build is used for a lot of other Mac programs, and I ended up having to reinstall my OS.

Comments

1

I had this error as well.

A simple change of ~/.profile or ~/.bash_profile of the path order fixed it. Before it was looking in /usr/bin first and not where things had been linked with homebrew.

export PATH=/usr/local/bin:$PATH

Comments

0

If you install yolk, you can see with

yolk -V matplotlib 

that version 1.3.1 of matplotlib is available. But pip won't let you install it because it is managed externally. The solution is to do:

pip install -Iv https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.tar.gz 

At first it didn't work for me though because of a problem with true type fonts. but I just had to google for the error message to find the solution on stackoverflow, which is to do the following before installing matplotlib:

ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.