Sid
Sid

Reputation: 4055

Getting started with Google Analytics API missing a package or wrong version of the package?

I downloaded the sample from getting started with Google Analytics API.

When I try to run it:

I get the following error:

pkg_resources.ContextualVersionConflict: (protobuf 3.0.0 (/usr/lib/python3/dist-packages), Requirement.parse('protobuf>=3.12.0'), {'google-api-core'})

What could be wrong?

I am not sure how to fix this. From what I understand protobuy version needs to be 3.12.0 while that is not present?

Upvotes: 0

Views: 4942

Answers (3)

Try this and reboot.

pip install protobuf==3.12.0

Upvotes: 0

snakecharmerb
snakecharmerb

Reputation: 55660

The error message is reporting a mismatch between the version of protocol buffers installed in your OS and the more recent version required by the GA API.

You could see if your OS's package manager can provide a more recent version of protocol buffers.

You could upgrade the OS's version using pip, but this is not a good idea; other packages may depend on the current version, and upgrading via pip will confuse the package manager.

I would suggest creating a virtual environment and installing protocol buffers and the GA API there.

python -m venv /path/to/myenv

Activate the virtual environment:

source /path/to/venv/bin/activate

Installed the packages in the virtual environment's Python.

pip install protobuf
pip install <name-of-google-analytics-api-package>

The virtual environment may be deactivated like this:

source /path/to/venv/bin/decativate

Upvotes: 1

Mrinal Roy
Mrinal Roy

Reputation: 979

As per the source code of latest Google API Core release it requires "protobuf >= 3.12.0",. So please do a install of protobuf 3.12.0 or the latest one pip install protobuf.

Upvotes: 1

Related Questions