Xia*_*hai 6 python macos wxpython anaconda
我在 mac 上安装了 anaconda 而不是系统的 python,但是当我输入时
import wx
app = wx.App()
Run Code Online (Sandbox Code Playgroud)
我懂了:
该程序需要访问屏幕。请使用 Python 的框架版本运行,并且仅当您在 Mac 的主显示屏上登录时才运行。
我使用脚本:
#!/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 "$@"
Run Code Online (Sandbox Code Playgroud)
但它只是使用系统python。不能在anaconda中使用lib。我想在anaconda中使用wx GUI,如何解决问题?
我通过阅读这篇文章解决了我的 Python 2 和 3 虚拟环境的问题(请参阅下面的提示):
我的环境是:
尖端: