Mac 上 wxPython 运行报错

老猫丶丶
  • 3
新手上路,请多包涵
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.

环境是

python 3.6.0
pyenv global 3.6.0
pip install wxpython

MacBook Pro:~ chenzhi$ python -c "import wx; print(wx.version())"
4.0.0b2 osx-cocoa (phoenix)

MacBook Pro:~ chenzhi$ which python
/usr/local/opt/pyenv/shims/python

MacBook Pro:MyGitlab chenzhi$ python -c "import site; print(site.getsitepackages())"
['/usr/local/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages']

MacBook Pro:MyGitlab chenzhi$ python -c "import sys,pprint; pprint.pprint(sys.path)"
['',
 '/usr/local/opt/pyenv/versions/3.6.0/lib/python36.zip',
 '/usr/local/opt/pyenv/versions/3.6.0/lib/python3.6',
 '/usr/local/opt/pyenv/versions/3.6.0/lib/python3.6/lib-dynload',
 '/usr/local/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages']
import wx
app = wx.App()
window = wx.Frame(None,title="wxPython",size = (400,300))
panel = wx.Panel(window)
label = wx.StaticText(panel,label = "hello world",pos = (100,100))
window.show()
app.MainLoop()

MacBook Pro:~ chenzhi$ python hello.py
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.
回复
阅读 4.3k
1 个回答
tthx
  • 15

如参考链接[1],你可能需要另外在你的执行环境下添加一个脚本来指定你的执行框架,详见链接。[1]https://github.com/conda/cond...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏