我有matplotlib 1.0.0安装在 Mac OS X 10.6 上的 Python 2.7 virtualenv 中。我可以很好地创建情节。但是,无论何时按下保存 按钮,我都无法在保存对话框窗口中键入文本,也无法保存绘图。我唯一能做的就是点击取消。关于导致此问题的原因以及如何解决它的任何想法?
Matplotlib安装过程
我通过克隆 astraw's matplotlib github repository 安装了 matplotlib然后松散地关注 HyperJeff's Installation Instructions for numpy/scipy/matplotlib .以下是 setup.cfg
和 make.osx
的潜在相关部分,包括我在编译和安装之前修改的部分。
设置.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
制作.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"
修改setup.cfg
和make.osx
后,我发出了以下命令来安装matplotlib:
make -f make.osx fetch deps mpl_build mpl_install
python setup.py install
注意 sudo
不是必需的,因为我正在安装到 virtualenv 中,而不是像 HyperJeff 那样安装到站点包中。
Python安装
我使用 python.org 的 Python 2.7 PPC/i386/x86-64 Mac OS X Installer Disk Image for Mac OS X 10.5 安装了 Python 2.7。感谢Ned Deily's answer to this SO question ,我知道这个版本的 Python 2.7 不能在 Mac OS X 10.6 上运行 IDLE 或 Tkinter。
问题
- 我安装的 Python 2.7 版本可能是问题的原因吗?我是否应该使用适用于 Mac OS X 10.3 到 10.6 的 Python 2.7 32 位 Mac OS X 安装程序磁盘镜像重新安装 Python 2.7?
- 是否需要在
setup.cfg
中配置不同的gui_support
选项,然后重新编译 matplotlib?
更新,2010 年 9 月 13 日,下午 3:33
看来其他 Mac OS X 和 matplotlib 用户也有同样的问题。在 matplotlib-users 邮件列表中,two users reported having the same problem on Mac OS X 10.5 .虽然,他们运行的是 matplotlib 0.99.1.1 和 0.99.1.2 而不是我安装的 matplotlib 1.0.0。
更新时间:2010 年 9 月 14 日上午 8:18
matplotlib bug 2973874于 2010 年 3 月 20 日以同样的问题开放。但是,它的优先级为 5,并且自从最初打开 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.
最佳答案
你需要让 OSX 相信 virtualenv 实际上是从应用程序包运行的。此处讨论修复:
并在这里实现:
关于python - 为什么保存按钮在 matplotlib 图上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3692928/