11

I have matplotlib 1.0.0 installed in a Python 2.7 virtualenv on Mac OS X 10.6. I can create plots fine. However, whenever I press the Save button, I can't type text into the save dialog window nor can I save the plot. The only thing I can do is hit cancel. Any thoughts on what's causing this and how to fix it?

alt text

Matplotlib installation procedure

I installed matplotlib by cloning astraw's matplotlib github repository and then loosely following HyperJeff's Installation Instructions for numpy/scipy/matplotlib. Below are the potentially relevant sections of setup.cfg and make.osx, including the sections that I modified prior to compiling and installing.

setup.cfg

[egg_info]
tag_svn_revision = 1

[directories]
basedirlist = /Users/matthew/.virtualenvs/matplotlib-test

[status]
#suppress = True
#verbose = True

[provide_packages]

[gui_support]
#gtk = False
#gtkagg = False
#tkagg = False
wxagg = False
#macosx = False

[rc_options]
backend = MacOSX
#numerix = numpy

make.osx

# build mpl into a local install dir with
PREFIX=/Users/matthew/.virtualenvs/matplotlib-test
MPLVERSION=1.0rc1
PYVERSION=2.7
PYTHON=python${PYVERSION}
ZLIBVERSION=1.2.3
PNGVERSION=1.2.39
FREETYPEVERSION=2.3.11
MACOSX_DEPLOYMENT_TARGET=10.6
OSX_SDK_VER=10.6
ARCH_FLAGS="-arch i386-arch x86_64"

## You shouldn't need to configure past this point (but I did...)

PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
CFLAGS="${ARCH_FLAGS} -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
LDFLAGS="${ARCH_FLAGS} -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"

PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
CFLAGS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
LDFLAGS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
FFLAGS="-arch i386 -arch x86_64"

After modifying setup.cfg and make.osx, I issued the following commands to install matplotlib:

make -f make.osx fetch deps mpl_build mpl_install
python setup.py install

Note: sudo isn't required, since I'm installing into a virtualenv instead of into the site-packages like HyperJeff is doing.

Python Installation

I installed Python 2.7 using python.org's Python 2.7 PPC/i386/x86-64 Mac OS X Installer Disk Image for Mac OS X 10.5. Thanks to Ned Deily's answer to this SO question, I know that this version of Python 2.7 cannot run IDLE or Tkinter on Mac OS X 10.6.

Questions

  1. Could the version of Python 2.7 that I have installed be the cause of the problem? Should I reinstall Python 2.7 using the Python 2.7 32-bit Mac OS X Installer Disk Image for Mac OS X 10.3 through 10.6?
  2. Is there a different gui_support option that I need to configure in setup.cfg and then recompile matplotlib?

Update, September 13, 2010, 3:33 PM

It appears that other Mac OS X and matplotlib users are having the same problem. In the matplotlib-users mailing list, two users reported having the same problem on Mac OS X 10.5. Although, they were running matplotlib 0.99.1.1 and 0.99.1.2 versus matplotlib 1.0.0 that I have installed.

Updated, September 14, 2010, 8:18 AM

matplotlib bug 2973874 was opened on 20-Mar-10 with the same issue. However, it's a priority 5 and hasn't been modified since the bug was originally opened. Below is the description from the bug:

I am running the 6.0.1 enthought python distibution 64bit Mac. If a run a plot and click save I get a save dialog window that opens, I canot enter text in the file name field. I can select an existing file but still cannot modify the name. If I select a non png file it does not overwrite it. I get a file with the same name but with the png extension.

Community
  • 1
  • 1
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
  • 1
    For reference, my stock 2.6 Python (for 10.6) and matplotlib 1.0 doesn't have this problem. No help there, sad to say. – Andrew Dalke Sep 12 '10 at 02:35
  • @Andrew — How did you install matplotlib? Also, don't sell your comment short—it's a valid data point. The fact that matplotlib works under the stock Python 2.6, could point toward the Python 2.7 framework with broken Tkinter support as the culprit. – Matthew Rankin Sep 12 '10 at 03:05
  • I experienced the same issue running Python 2.7 in virtualenv in 10.7. The answer below fixed the issue for me. – gcorne Dec 09 '11 at 04:13
  • @AndrewDalke was yours through a virtualenv or using system python? – Gregg Lind Dec 29 '11 at 23:32
  • That was the system Python. I also have Python 2.7, compiled directly into /usr/local/, and that doesn't have a problem. – Andrew Dalke Dec 30 '11 at 15:54
  • @AndrewDalke, System python should be unaffected by this, good to confirm it! – Gregg Lind Jan 03 '12 at 16:45
  • I'm using python-2.7.3 (via pythonbrew), with pip-installed matplotlib-1.1.0, on OS X 10.6.8, and I most definitely *do* have this annoying problem. I'm not using virtualenv so I don't think the solution below is helpful to me. Still investigating... – davidA Jul 10 '12 at 02:47

4 Answers4

7

You need to convince OSX that the virtualenv is actually running from an Application Bundle. Fix discussed here:

http://groups.google.com/group/python-virtualenv/browse_thread/thread/83fa4a12d22a30c8/744e19c194f1618a

And implemented here:

https://github.com/gldnspud/virtualenv-pythonw-osx

  • what is the 'env_path' in this script @thouis? – Gregg Lind Dec 29 '11 at 23:26
  • I believe it's the path to the virtualenv. –  Dec 30 '11 at 10:49
  • Hm. I am not seeing any '.Python' dir in my ``~/virtualenvs``. – Gregg Lind Dec 30 '11 at 15:34
  • Odd. What version of virtualenv are you using? I'm on 1.5.1. –  Jan 03 '12 at 08:38
  • thouis, it was because my venv was based on the ``brew install`` (non Framework) version of python, not the system one. I have rolled in the method you link to at https://github.com/pypa/virtualenv/issues/54 – Gregg Lind Jan 03 '12 at 16:44
  • 1
    Worked great for me. OS X Lion, python 2.7.2 built from source as a framework, matplotlib from source. – physicsmichael May 09 '12 at 22:48
  • Hi, I am having a similar problem and I wanted to implement this solution. So I tried to run the install_pythonw.py like this: laura$ python install_pythonw.py `which python`/../.. and I got: /Library/Frameworks/EPD64.framework/Versions/Current/.Python does not exist; exiting. any idea? I am using a mac with snow Leopard and EPD 7.3-2 (64-bit). Thanks! – Laura Dec 06 '12 at 22:54
1

My answer doesn't fix the problem but can workaround it easily! You can touch a new file with the correct file extension in a terminal. After you can choose this file with the mouse inside the matplotlib window and overwrite it.

bougui
  • 3,507
  • 4
  • 22
  • 27
1

To solve this:

Use conda install python.app to install pythonw.

Then use pythonw instead of python in your terminal.

E.g.

pythonw my_plot.py

Hope this helps

seralouk
  • 30,938
  • 9
  • 118
  • 133
0

For those that Thouis method didn't work:

I noticed that a simple work around is to change matplotlib backend. Here is a list of available backends:

http://matplotlib.org/faq/usage_faq.html#what-is-a-backend

Note that you should choose one of the renderer ones (i.e. the ones that support show() command). You might need to install the backend, but you might have multiple ones installed.

To do so:

import matplotlib
matplotlib.use('Qt4Agg')    #replace 'Qt4Agg' with desired backend

Warning: This should be done BEFORE importing pylab, etc.

Bersavosh
  • 13
  • 2