The following solved it for me.
I found the location of the GDAL site-packages by typing
osgeo in the python console in QGIS:
<module 'osgeo' from '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/osgeo/__init__.py'>
I read that the directory where your module lives has to be in your python path, and when I checked it wasn't there:
>>> import sys
['', '/Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages', '/Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages/osgeo', '/Users/<my_user_name>', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages', '/usr/local/Cellar/numpy/1.15.0/libexec/nose/lib/python3.7/site-packages']
So I added that path to my python path. For me that meant editing my ZSH profile (
vi ~/.zshrc), but if you don't use ZSH you'll want to edit your bash profile or whatever you do use. In any case, I just added this line:
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages:$PYTHONPATH"` to my bash profile
Then I reloaded my profile (
source ~/.zshrc or open a new shell), started the python console again, and it worked!