Navigate to the symbolic link to Python3 within the QGIS application at /Applications/QGIS.app/Contents/MacOS/bin/python3. This will open a Terminal window with a message about the version of Python is running and will end with the interactive prompt >>>.
import os
os.system('/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install pyOpenGL')
os.system('/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install pyOpenGL_accelerate')