wxPython 4.2.0 on macOS (Apple silicon) only runs under sudo

Like the title says. I can pip install wxpython just fine but using it segfaults at the point where I import wx

If I import fault handler first, I get the following trace:

Fatal Python error: Segmentation fault

Current thread 0x0000000103114580 (most recent call first):
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1173 in create_module
  File "<frozen importlib._bootstrap>", line 565 in module_from_spec
  File "<frozen importlib._bootstrap>", line 666 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "/opt/homebrew/lib/python3.9/site-packages/wx/core.py", line 12 in <module>
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 850 in exec_module
  File "<frozen importlib._bootstrap>", line 680 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "/opt/homebrew/lib/python3.9/site-packages/wx/__init__.py", line 17 in <module>
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 850 in exec_module
  File "<frozen importlib._bootstrap>", line 680 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "/Users/garethsimpson/test.py", line 5 in <module>
[1]    74566 segmentation fault  python3.9 test.py

If I run under sudo, everything works perfectly.

I use wxPython 4.2.0 on macOS and do not have any issues running without sudo. I’ve installed wxPython on several different macOS versions using both python 3.9 and python 3.7. I use virtual environments through venv, if that makes any difference.

David

Hi all,

I recently noticed that FloatCanvas Rubberband boxes have stopped
working on macOS.

Take a look at the FloatCanvas sample program “DrawRect.py” that comes
with the wxPython Demos and Samples. It’s a very simple program that
draws rectangles, showing a rubberband box as you draw.

At least, that’s how it works on Windows and on macOS Catalina and
older. I’ve noticed, however, that on macOS Monterey and Ventura, the
rubberband box doesn’t show up. The program draws the rectangle you’d
expect, but you don’t get to see the rubberband box as you draw it.

I see this with wxPython 4.2.0 and python 3.7 or 3.9.

Any thoughts or suggestions?

David