为什么在使用virtualenv时,Python构建突然不是Framework构建? [英] Why are Python builds suddenly not Framework builds when using virtualenv?
问题描述
我已经在Mac上安装了Python 2.7作为Framework构建.我已经安装并确认wxPython可以与此Python版本一起使用.但是,当我使用virtualenv创建虚拟环境时,生成的Python可执行文件不是Framework构建版本,或者至少不是根据wxPython:
I've installed Python 2.7 as a Framework build on my Mac. I've installed and confirmed that wxPython works with this Python build. But when I create a virtual environment with virtualenv, the resulting Python executable isn't a Framework build, or at least not according to 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:
Another solution is to add the following script to /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是 active )
Then, whenever you want to run GUI (ex wxPython) use my_script main.py
(make sure that virtualenv is active)
这篇关于为什么在使用virtualenv时,Python构建突然不是Framework构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!