在 OS X 上为 Python 3.3 试用 wxPython Phoenix。(我不确定 Python 3 Phoenix 支持哪个版本,我强制安装它。
>>> import wx
>>> wx.App()
This program needs access to the screen. Please run with a
Framework build of python, and only when you are logged in
on the main display of your Mac.
现在我读到这篇文章说 wxPython 与 virtualenv 存在问题,并通过此脚本提供了修复:
#!/bin/bash
# what real Python executable to use
PYVER=2.7
PYTHON=/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python$PYVER
# find the root of the virtualenv, it should be the parent of the dir this script is in
ENV=`$PYTHON -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`
# now run Python with the virtualenv set as Python's HOME
export PYTHONHOME=$ENV
exec $PYTHON "$@"
我看不懂 BASH(什么是 $@?),但看起来这只是设置 PYTHONHOME 的问题。我在 Python 3 上运行 wxPython Phoenix,而不是 Python 2。而且我没有使用 virtualenv。我是米尼康达。我不知道在哪里设置 PYTHONHOME。我将它设置在 PYTHONHOME="/Users/username/miniconda3/" 但它不起作用。