【发布时间】:2014-06-10 07:05:32
【问题描述】:
在 OS X 上试用 wxPython Phoenix for Python 3.3。(我不确定 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.
现在我读到this,它说 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/" 中设置了它,但它不起作用。
【问题讨论】:
-
$@是脚本的参数。在设置一些环境变量之后,它只是将它们转发给 python。
标签: python python-3.x wxpython anaconda miniconda