Streamlit and Google API client protobuf version

I have a issue with using Streamlit and Google API Python client as it uses Protobuf 4.22 and Streamlit on the other hand is suggesting to downgrade the protobuf package to 3.20 or lower. And because Im a newbie I don’t know how to set protocol_buffer_python_implementation = python but this method is much slower. I have Macbook Air M1 (2020), and there is no clear instruction so that I can solve this issue.

Are you sure google-api-python-client requires protobuf>=4? I installed it alongside streamlit==1.19.0 and protobuf==3.20.3 and I got no warnings from pip.

Please be specific, which one do you use, there are different google api python clients out there.

It is an ongoing annoyance. The issue (at least for me) is with the grpcio-status package demanding protobuf > 4. The easiest way to fix it is to uninstall protobuf, grpcio-status, and any other google packages pip is complaining about, then reinstall all of them together but specifying protobuf==3.20.3. You may need to uninstall streamlit first and then reinstall it afterwards.

Being specific, the command I wrote was,
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Which then installed, protobuf-4.22.0 and you know that streamlit will only use protobuf package to 3.20.x or lower.

1 Like

Indeed, even the current version 1.19.0 of streamlit has these constraints in the setup.py file regarding protobuf dependency:

"protobuf<4,>=3.12",

If you update single packages you get of course warnings from pip about incompatibilities.
Do you absolutely need protobuf >= 4 in one of your dependencies?
Because the google-api-python-client does not need it.
When I install these two packages together in a clean environment, I get no conflicts and pip resolves these versions for me, as @Goyo already wrote either.

requirements.txt
streamlit
google-api-python-client
pip list
package                  Version
------------------------ -----------
google-api-core          2.11.0
google-api-python-client 2.79.0
google-auth              2.16.1
google-auth-httplib2     0.1.0
googleapis-common-protos 1.58.0
protobuf                 3.20.3
streamlit                1.19.0
# and of course some other packages as well...

So what should I do, and if there is any solution to this problem? Also how to set protocol_buffer_python_implementation = python, and if it is a viable solution to this problem?
Maybe I can uninstall the google client to download it again?

pip install protobuf<4,>=3.12

Shun ham
The command you want is

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib protobuf==3.20.3

Which forces pip to only use package versions compatible with that version of protobuf. It should work, but if not uninstall all the google packages, including the grpcxxx ones and other dependencies, and reinstall with the command above.

1 Like

Thanks for your help, Now I can go ahead with my project! Thank you Everyone in this thread @Franky1 @Goyo, for helping me troubleshoot the problem!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.