How to run wxPython with the installer on macOS 12.4 (Monterey)

I asked this question on stackoverflow but probably should have asked here:

I want to install python from and have it work with wxPython in a terminal on macOS:

  • Install python 3.9.13 using the macOS 64-bit universal2 installer
  • Install wxPython using pip - pip3 install -U wxPython
  • Start python in a shell and try and fire up a wx app:
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 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. I have read lots and lots of posts with the same error but different environmental setup. Thanks for any help.

It should work. I almost exclusively use the stock builds from When you run those commands are you using a native local terminal or something like ssh or other remote access to the machine?

Also, please try again with the newest build.

I’m using a native terminal. I tried with the newest build. I feel like something is messed up in my environment, but cannot figure out what it is.