Mac 上 wxPython 运行报错

发布于 2022-09-06 12:47:09 字数 1339 浏览 10 评论 0

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伴随着你 2022-09-13 12:47:09

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文