Not sure this is a general fix, but it solved my particular need for GLPK. I just reverted back to an older version and it worked.
First uninstall the newest:
brew remove glpk
Then install an old one (4.39).
cd $(brew --prefix)
git checkout a82e823 Library/Formula/glpk.rb
brew install glpk
Then this worked just fine:
pip install glpk