简体   繁体   中英

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?

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 .

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

Try this and reboot.

pip install protobuf==3.12.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM