简体   繁体   English

开始使用 Google Analytics API 缺少 package 或 package 的错误版本?

[英]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.我从 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'}) 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?据我了解,protobuy 版本需要为 3.12.0,而该版本不存在?

As per the source code of latest Google API Core release it requires "protobuf >= 3.12.0", .根据最新 Google API Core 版本的源代码,它需要"protobuf >= 3.12.0", So please do a install of protobuf 3.12.0 or the latest one pip install protobuf .所以请安装protobuf 3.12.0或最新的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.错误消息报告操作系统中安装的协议缓冲区版本与 GA API 所需的更新版本不匹配。

You could see if your OS's package manager can provide a more recent version of protocol buffers.您可以查看您的操作系统的 package 管理器是否可以提供更新版本的协议缓冲区。

You could upgrade the OS's version using pip, but this is not a good idea;您可以使用 pip 升级操作系统的版本,但这不是一个好主意; other packages may depend on the current version, and upgrading via pip will confuse the package manager.其他软件包可能取决于当前版本,通过 pip 升级会混淆 package 管理器。

I would suggest creating a virtual environment and installing protocol buffers and the GA API there.我建议创建一个虚拟环境并在那里安装协议缓冲区和 GA API。

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.在虚拟环境的 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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