google-generativeai and protobuf conflicting dependencies

pipreqs is a python package that generates requirements.txt file from your python project. And it works great unless you run into conflicting versions or it stops picking up imported libs.

How did I end up here?

Might be very specific to google-generativeai version 0.5.2

While working on a project using google-generativeai package from google, ran pipreqs to generate a requirements.txt file. So 2 things to note here it didn't include google-generativeai and but protobuf was included. I had to manually add google-generativeai "0.5.2" version.

When did I got this error?

git push and boom 💥 goes the deployment to vercel.

Error: Command failed: pip3.9 install --disable-pip-version-check --target . --upgrade -r /vercel/path0/requirements.txt
ERROR: Cannot install -r /vercel/path0/requirements.txt (line 6), google-generativeai and protobuf==5.26.1 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Fix :

The error is self explanatory, so i removed protobuf reference from the requirements.txt file(as it's already included with google-generativeai). Anyways git push and success!✌🏼

Back To All Blogs