gpt4 book ai didi

python - wxPython:该程序需要访问屏幕

转载 作者:行者123 更新时间:2023-12-02 09:03:11 25 4
gpt4 key购买 nike

我正在尝试在以下最小应用程序中使用 Python GUI wx(可通过 pip install wxPython 安装):

import wx
app = wx.App()

运行此代码片段会返回以下内容:

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.

有谁知道如何帮助wx获得“访问屏幕”,或者什么是“Python框架构建”?如果其他人能够针对这些问题提供任何帮助,我将不胜感激!

最佳答案

虚拟环境中 Mac 上的 wxPython 会引发此错误,如 wxPython 网站所解释:https://wiki.wxpython.org/wxPythonVirtualenvOnMac

如果您没有在虚拟环境中运行它并且仍然收到此错误,请尝试运行使用 wxpython 的脚本,其中包含“pythonw”而不是“python”。例如:

pythonw hello.py

^请参阅 Python 文档中下一页的“4.1.2 使用 GUI 运行脚本”(在 MacOS 上)一节,了解此 python 怪癖的解释:https://docs.python.org/3/using/mac.html

关于python - wxPython:该程序需要访问屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48531006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com