Reputation: 583
I want to install python from python.org and have it work with wxPython in a terminal on macOS:
pip3 install -U wxPython
DB0837:~ andypiper$ /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> 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.
Please don't point me at brew or pyenv or anaconda or framework builds - I want the above combination to work, and it seems not to. The download from python.org is a framework build and if I run this from IDLE it works fine using the exact same version of python, so it feels like it must be some macOS security issue or shell/python interaction
Upvotes: 3
Views: 488
Reputation: 37671
I had this problem on an existing codebase after upgrading to Monterey.
My app still worked when built with py2app, but not when running from the command line.
It seems like the underlying wxWidgets method IsDisplayAvailable
started to fail, so I just removed the check.
It's in your site packages at wx/core.py
, line 2183.
Change
if not self.IsDisplayAvailable():
to
if False:
and you are off to the races.
What can I say? It's very dirty, but I'm working again.
Upvotes: 6