Repository navigation
Description
Looking through other issues, guessing this isn't new per se. Looks like this all began as a Python v2 script that's been brought to v3 but still tied to some older modules.
For reference my system:
- 2019 27" iMac with Core i5 and 32GB RAM
- macOS 13.2
- Python.org's Python 3.11.2
- Command Line Tools for Xcode 14.2
Did a git clone of repo.
First attempt to run script:
% ./mcxToProfile.py
zsh: ./mcxToProfile.py: bad interpreter: /usr/bin/python: no such file or directory
Looking at file, I see top line shows #!/usr/bin/python. Yeah, that's not gonna work. Modified it to #!/usr/bin/python3 and re-ran script. Now I get
% ./mcxToProfile.py
Traceback (most recent call last):
File "/Users/frank/Desktop/mcxToProfile/./mcxToProfile.py", line 15, in <module>
from Foundation import NSData, \
ModuleNotFoundError: No module named 'Foundation'
I did some digging and seems that the underbelly of this relies on something called PyObjC. I tried installing it after finding it on PyPi.org, but pip install pyobjc failed miserably.
Found the source code for that here: https://github.com/ronaldoussoren/pyobjc
So cloned it into the directory where I had this script. I setup a virtual environ using virtualenv venv followed by source venv/bin/activate, so I can sandbox this setup somewhat.
At that point I followed the instructions and tried to do python3 pyobjc/install.py but that failed due to not being able to import _install_tool. I moved down into ./pyobjc and re-ran it as python3 install.py, and THAT seemed to do the trick. Got lots of warnings/etc., but it spent the next 20+ minutes compiling. Sadly, that ended badly with
...
^
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pyobjc-framework-WebKit
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Installing 'pyobjc-framework-WebKit' failed (status 1)
Cannot build one of the projects, bailing out
So still can't run this.
Anyway, so looks like this "Foundation" module isn't installed, nor can I get the bits going to do so.
If I had to guess, this script relies on features not found on stock macOS systems. Is that a fair assessment? If there are dependencies, might it not help to articulate them in the README.md file so users have a better chance of using this tool? It feels like this could do with a requirements.txt or similar file to let folks know what is expected.
I came here as I was dealing with a Munki issue and multiple references mentioned this particular tool. Sadly looks like it's not quite as simple to use as they made it sound.
Activity
macmule commentedon Feb 13, 2023
MehdiYawari commentedon Feb 24, 2023
I am on macOS Monterey 12.6.3 und have already updated my python to the latest version(3.11.2). But I still get the following error:
Traceback (most recent call last):
File "/Users/taayame4/Desktop/mcxToProfile.py", line 15, in
from Foundation import NSData,
ModuleNotFoundError: No module named 'Foundation'
How do I get any other python3 if not Apple's python3?
Sorry, dont have much experience with the python
luckman212 commentedon Feb 24, 2023
I had to change the shebang from
#!/usr/bin/env pythonto#!/usr/bin/env python3and make sure to install python@3 from Homebrew — and I thinkpip install pyobjcto be able to import the Foundation module.simX commentedon Sep 13, 2025
This project is still being referenced from a Chrome Enterprise and Education help document here: https://support.google.com/chrome/a/answer/9020077
I briefly ran into this same issue, so I'll go through how I fixed it:
Then you need to edit the shebang line at the top of the script to use the virtual environment:
#!/Users/username/mcx/pyobjc-venv/bin/python3Then you can run the script and it should work:
./mcxToProfile.py --plist chrome-policies.plist --identifier com.google.Chrome