Running wxPython 2.9 on OS X 10.8 (64 bit)

时间秒杀一切 提交于 2019-12-08 07:08:44

问题


I have EPD 7.3 and have installed wxPython 2.9 through the Enthought repositories. I tried running winPDB, which requires wxPython and I got this message :

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.

I have seen similar messages from wxPython on Mac, but I haven't found a solution yet. Does anyone know about this message? And, has anyone got WinPDB to work on OS X 10.8 w/ wxPython 2.9?


回答1:


This error message will happen when the Python used to run a wxPython script is not a full framework build. OSX requires that applications that are given full access the screen be run from an application bundle or are part of a framework.

Usually all Pythons are framework builds these days and there is no need to worry about this any more, however there is one situation where it is still an issue, and that is with virtualenv or similar tools. With the way that the virtualenv is constructed the Python that is there sort of loses its connection with the framework that it comes from, and so using it directly triggers that security mechanism and the wx code is not able to get full access to the screen. If you are experiencing a problem in a virtualenv then I've written up a workaround here: http://wiki.wxpython.org/wxPythonVirtualenvOnMac

Hmm... I just went to double-check this with EPD and I found that the "python" executable they provide is not a front-end for the Python.app binary like in normal framework builds, but is more like a normal unixy Python. Since I'm at Enthought now I'll ask the responsible parties if this is a bug or is intended, but in the meantime you can work around this by changing which Python is being executed. For example, you could create a "pythonw" alias in your bash shell that points to the Python.app binary, like this:

alias pythonw=/Library/Frameworks/EPD64.framework/Versions/7.3/Resources/Python.app/Contents/MacOS/Python

Then you should be able to run WinPDB or other wxPython applications by using pythonw instead of python.



来源:https://stackoverflow.com/questions/15746518/running-wxpython-2-9-on-os-x-10-8-64-bit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!