在运行别人代码导入tensorflow包时,出现该问题。
AttributeError: module ‘google.protobuf.internal.containers’ has no attribute ‘MutableMapping’
解决方法:
(1)检查protoc和protobuf的版本是否一致
(avod) [root@localhost avod]# protoc --version
libprotoc 3.19.4
(avod) [root@localhost avod]# pip show protobuf
Name: protobuf
Version: 3.19.4
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author: None
Author-email: None
License: 3-Clause BSD License
如果不一致,那么重装protoc或者protobuf
重装protoc
下载https://github.com/google/protobuf/releases ##Source code (zip)##
./autogen.sh
./configure
make
make check
make install
重装protobuf
sudo pip install protobuf
(2)在本地python依赖site-packages/google/protobuf/internal/container.py中添加一行代码(来源)
from collections.abc import MutableMapping
问题解决!