Hi there, I’m having issue with the python3 installation provided by Xcode’s toolchain. I’m currently writing a LLDB plugin, using the LLDB python API, to allow the user to visualize audio data from the current debugged program in a GUI, using tkinter and matplotlib. I'm using those because I'm developing a cross-platform plugin, as I'm initially a Linux developer who wants to make this available to my fellow Apple audio devs.
My issue arise at least on two setups
MacOS 12.7.6 Monterey with Xcode 14.2
MacOS 14 with Xcode 15.4 (not my machine)
Because I wanna support Xcode’s toolchain, I want to use Xcode’s lldb. Xcode’s lldb uses Xcode’s provided python, which I’m having issues with when loading tkinter.The issue can be reproduced like this :
> xcrun python3 -c "import tkinter;tkinter._test()"
macOS 12 (1207) or later required, have instead 12 (1206) !
zsh: abort xcrun python3 -c "import tkinter;tkinter._test()"
On MacOS 14 the version numbers are :
macOS 14 (1407) or later required, have instead 14 (1406) !
You can see it fails to load tkinter. From what I understood so far, it looks like the tkinter/tcl/tk version distributed with Xcode is not supported by MacOS ?I checked and the imported tkinter module is definitely the one provided by Xcode’s toolchain :
# Checking where tkinter is installed
> fd "^tkinter$" /Applications/Xcode.app
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/tkinter/
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages/future/moves/tkinter/
# Checking that Xcode python uses the right module - it matches
> xcrun python3 -c "import tkinter;print(tkinter.sys.modules['tkinter'])"
<module 'tkinter' from '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py'>
I can get a working tkinter working by installing it using homebrew or macports, but I’m not able to use it with Xcode’s python installation. I tried overwriting sys.path to force Xcode’s python to import homebrew’s tkinter module, but it still loads Xcode’s tkinter .so.
In the crash report I can see it indeed loads tcl/tk 8.5 and loads _tkinter.cpython-39-darwin.so from Xcode. I could disable the SIP (System Integrity Protection) to force to load another version of the library, but that wouldn’t be something I can ask the users.
On the LLDB forum, they advise against using another python interpreter that the one provided by the toolchain. So is there a way to get the provided tkinter/tcl/tk installation to work ? If not I’m confused about why it’s provided in the first place.
Thanks a lot for your time and please tell me if you have any questions.
PS: if possible i'll post the head of the crash report in the comment of this post