Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

python - Why doesn't the save button work on a matplotlib plot?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...