Closed MusicMaker81 closed 1 year ago
What Python are you using? That error looks like you are using a Python without PyObjC installed.
What Python are you using? That error looks like you are using a Python without PyObjC installed.
Version 3.9.6
Sorry, I wasn't clear. Where did you source your Python? If you installed Python that does not include PyObjC, you will need to install that. Or install a Python that includes it.
From the readme :
Some options for providing an appropriate Python:
1) If you also use Munki, use Munki's bundled Python, available at /usr/local/munki/munki-python 2) Install Python from macadmins-python (https://github.com/macadmins/python). 3) Install Python from https://www.python.org. 5) There are other ways to install Python, inlcuding Homebrew (https://brew.sh), my relocatable-python tool (https://github.com/gregneagle/relocatable-python), using the python3 bundled with Xcode, and more. 6) Notably, if you don't use options 1 or 2 above, and install Python some other way, you'll also need to install PyObjC.
@MusicMaker81 Due to Apple's stupid decision to stop including a copy of python as standard in macOS, either developers need to include it with their tool - like Munki and AutoPkg do amongst others, or you as a user need to install a copy yourself.
As mentioned by @vmiller the MacAdmins group have created a pre-built python installer pkg and Greg Neagle has also created a copy but you need to do some work with that, or you can use the one included with another existing tool.
Once you know you have a copy of python installed - even one installed as part of another tool you can call it to run a python script, you can also call it and ask it what modules it has included. Due to Apple's foolish decision you could have several different copies - each a different version and each with different modules included. (The stupidity of Apple is that instead of one copy that is properly maintained and updated you have an unknown number of copies all of which are likely on different versions and possibly open to different security issues.)
There are ways to ask a copy of python what modules it has included, here is an example using the python from Munki.
/usr/local/munki/munki-python -m pip list
or if using the MacAdmins copy of python
/usr/local/bin/managed_python3 -m pip list
This will use the pip module to list other modules. Some copies of python may not have pip installed and whilst you could install pip there are some other ways to ask python for a list of modules. See the following article.
https://www.activestate.com/resources/quick-reads/how-to-list-installed-python-packages/
Note: If you are writing your own python script and want it to be run using a specific copy of python you need to set this on the 'shebang' line i.e. the first line of the script like the following.
#!/usr/local/bin/managed_python3
When running this on Ventura I get this:
Traceback (most recent call last): File "/Users/Shared/Temp/pycreateuserpkg-main/./createuserpkg.py", line 28, in
from locallibs import shadowhash
File "/Users/Shared/Temp/pycreateuserpkg-main/locallibs/shadowhash.py", line 24, in
from . import plistutils
File "/Users/Shared/Temp/pycreateuserpkg-main/locallibs/plistutils.py", line 22, in
from Foundation import NSPropertyListSerialization
ModuleNotFoundError: No module named 'Foundation'
So the package for the specified account is not made.