python - tensorflow 2.3.1 和 cirq 之间的 protobuf 版本冲突
问题描述
目前开始学习 TFQ 并一直在尝试做这个tensorflow 作者的教程,但是如果我运行第一行 (!pip install -q tensorflow==2.3.1 --user) 我得到这个错误:
错误:pip 的依赖解析器当前不考虑所有已安装的包。此行为是以下依赖冲突的根源。cirq 0.8.0 需要 protobuf==3.8.0,但您有 protobuf 3.15.7,这是不兼容的。
当我运行第二行(!pip install -q tensorflow-quantum --user)时,我得到了这个:
错误:pip 的依赖解析器当前不考虑所有已安装的包。此行为是以下依赖冲突的根源。tensorflow 2.3.1 需要 protobuf>=3.9.2,但是你有 protobuf 3.8.0 是不兼容的。
Cirq 0.8.0 想要 protobuf 3.8.0;tensorflow 2.3.1 想要 protobuf>=3.9.2 并且中间没有任何东西,当我执行“pip freeze”时,我只看到 protobuf==3.8.0,所以我的 pip freeze 看不到 protobuf 3.15.7 版本错误提到(当我执行“pip show protobuf”时,我得到了与版本 3.8.0 相同的结果)。
我应该怎么做才能防止这种冲突?
注意:Python 版本 = 3.7.9(无法使用 3.8 或 3.9 安装 tf 和/或 tfq);操作系统 = Windows 10
解决方案
在同一环境中安装两个不同的软件包会覆盖其他大部分软件包。这就是 pip 的工作方式。建议为每个包使用虚拟环境。
python -m tf_nightly --system-site-packages .\venv
.\venv\Scripts\activate
pip install --upgrade pip
pip install tf-nightly
推荐阅读
- java - 使用模块时不会加载 Artemis 资源适配器。使用存档加载正常。为什么?
- python - 计算按日期和标签分组的行中列表元素的频率
- php - Laravel 相当于 ->fetch?
- sql - 根据可变日期范围(impala)在窗口上对列值求和
- c++ - Colored boost::log 显示变换的颜色
- javascript - 将键盘事件与 textareas 一起使用
- php - 我应该如何设置 Mailhog 以使用 Docksal?
- c# - 我想添加一个字符串扩展方法。但是我应该在我的 Xamarin Forms 应用程序中的哪里添加它,以便它在任何地方都可用?
- python - sklearn train_test_split 死亡并关闭 python 内核
- swift - Swift 4 AVMutableComposition 动画