When you start using AutoPKG’s custom processor you may encounter python errors about missing libraries or modules. The worst offender is probably the requests module which get’s used often in custom processors:

% autopkg run com.gitlab.autopkg.some.recipe
Processing com.gitlab.autopkg.some.recipe...
WARNING: /Users/marcel/Library/AutoPkg/RecipeRepos/com.gitlab.autopkg.some.recipe/PostProcessors/SomeCustomProcessor.py: No module named 'requests'

If you would install the module simply via the ususal way e.g. pip3 install requests the problem would persist. The reason why is, that AutoPKG uses it’s own python binary and a custom location for libraries and modules.

Custom AutoPKG python binary in the System Library folder

The binary is located under /Library/AutoPkg/Python3/Python.framework/Versions/Current/bin/python3. So the path for modules and the python library is /Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7. Custom installed modules get installed under /Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7/site-packages/.

Simply use the AutoPKG’s pip binary!

To install modules in the right location you don’t need to move files or folders by hand (nor should you fiddle in these locations anyawy if you are not firm with python’s structure).

You can simply use the included pip binary to install modules. Remember to use sudo since you need root privileges to add files to the System Library:

sudo /Library/AutoPkg/Python3/Python.framework/Versions/Current/bin/pip3 install requests

The requests module would be installed under /Library/AutoPkg/Python3/Python.framework/Versions/Current/lib/python3.7/site-packages/requests/ and AutoPKG is able to use it.