我在我的 Mac 上安装了 Python 2.7 作为框架构建。我已经安装并确认 wxPython 可以与这个 Python 构建一起工作。但是当我使用 virtualenv 创建虚拟环境时,生成的 Python 可执行文件不是框架构建,或者至少根据 wxPython 不是:
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.
有什么想法吗?
最佳答案
另一种解决方案是将以下脚本添加到/Path/To/VirtualEnv/bin:
ENV=`python -c "import sys; print sys.prefix"`
PYTHON=`python -c "import sys; print sys.real_prefix"`/bin/python
export PYTHONHOME=$ENV
exec $PYTHON "$@"
然后,每当你想运行 GUI(例如 wxPython)时,使用 my_script main.py
(确保 virtualenv 事件)
关于python - 为什么使用 virtualenv 时 Python 构建突然不是 Framework 构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13249880/