Protobuf throwing Type error `TypeError: bases must be types` in m1 mac


@GopikrishnanSasikumar I tried to replicate the issue reported here and didn't face the issue, could you please have a look at the logs below and let me know if i am missing anything here. Thank you!
```
(base) suryanarayanay-macbookpro:~ suryanarayanay$ pip install tensorflow==2.13
Collecting tensorflow==2.13
  Downloading tensorflow-2.13.0-cp310-cp310-macosx_12_0_arm64.whl (1.9 kB)
Collecting tensorflow-macos==2.13.0
  Downloading tensorflow_macos-2.13.0-cp310-cp310-macosx_12_0_arm64.whl (189.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 189.3/189.3 MB 11.1 MB/s eta 0:00:00
Collecting tensorboard<2.14,>=2.13
  Using cached tensorboard-2.13.0-py3-none-any.whl (5.6 MB)
Requirement already satisfied: astunparse>=1.6.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (1.6.3)
Requirement already satisfied: libclang>=13.0.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (16.0.0)
Requirement already satisfied: wrapt>=1.11.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (1.14.1)
Requirement already satisfied: numpy<=1.24.3,>=1.22 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (1.22.3)
Collecting tensorflow-estimator<2.14,>=2.13.0
  Downloading tensorflow_estimator-2.13.0-py2.py3-none-any.whl (440 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 440.8/440.8 kB 18.4 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions<4.6.0,>=3.6.6 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (4.5.0)
Requirement already satisfied: flatbuffers>=23.1.21 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (23.3.3)
Requirement already satisfied: termcolor>=1.1.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (2.2.0)
Requirement already satisfied: six>=1.12.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (1.16.0)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (1.53.0)
Collecting keras<2.14,>=2.13.1
  Downloading keras-2.13.1-py3-none-any.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 19.4 MB/s eta 0:00:00
Requirement already satisfied: h5py>=2.9.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (3.6.0)
Requirement already satisfied: setuptools in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (65.6.3)
Requirement already satisfied: packaging in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (23.0)
Requirement already satisfied: absl-py>=1.0.0 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (1.4.0)
Requirement already satisfied: gast<=0.4.0,>=0.2.1 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (0.4.0)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (4.22.3)
Requirement already satisfied: google-pasta>=0.1.1 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (0.2.0)
Requirement already satisfied: opt-einsum>=2.3.2 in ./miniconda/lib/python3.10/site-packages (from tensorflow-macos==2.13.0->tensorflow==2.13) (3.3.0)
Requirement already satisfied: wheel<1.0,>=0.23.0 in ./miniconda/lib/python3.10/site-packages (from astunparse>=1.6.0->tensorflow-macos==2.13.0->tensorflow==2.13) (0.37.1)
Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in ./miniconda/lib/python3.10/site-packages (from tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (1.0.0)
Requirement already satisfied: werkzeug>=1.0.1 in ./miniconda/lib/python3.10/site-packages (from tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (2.2.3)
Requirement already satisfied: requests<3,>=2.21.0 in ./miniconda/lib/python3.10/site-packages (from tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (2.28.1)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in ./miniconda/lib/python3.10/site-packages (from tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (0.7.0)
Requirement already satisfied: markdown>=2.6.8 in ./miniconda/lib/python3.10/site-packages (from tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (3.4.3)
Requirement already satisfied: google-auth<3,>=1.6.3 in ./miniconda/lib/python3.10/site-packages (from tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (2.17.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in ./miniconda/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (0.2.8)
Requirement already satisfied: rsa<5,>=3.1.4 in ./miniconda/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (4.9)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in ./miniconda/lib/python3.10/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (5.3.0)
Requirement already satisfied: requests-oauthlib>=0.7.0 in ./miniconda/lib/python3.10/site-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (1.3.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./miniconda/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (1.26.14)
Requirement already satisfied: certifi>=2017.4.17 in ./miniconda/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (2022.12.7)
Requirement already satisfied: idna<4,>=2.5 in ./miniconda/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (3.4)
Requirement already satisfied: charset-normalizer<3,>=2 in ./miniconda/lib/python3.10/site-packages (from requests<3,>=2.21.0->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (2.0.4)
Requirement already satisfied: MarkupSafe>=2.1.1 in ./miniconda/lib/python3.10/site-packages (from werkzeug>=1.0.1->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (2.1.2)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in ./miniconda/lib/python3.10/site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (0.4.8)
Requirement already satisfied: oauthlib>=3.0.0 in ./miniconda/lib/python3.10/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard<2.14,>=2.13->tensorflow-macos==2.13.0->tensorflow==2.13) (3.2.2)
Installing collected packages: tensorflow-estimator, keras, tensorboard, tensorflow-macos, tensorflow
  Attempting uninstall: tensorflow-estimator
    Found existing installation: tensorflow-estimator 2.12.0
    Uninstalling tensorflow-estimator-2.12.0:
      Successfully uninstalled tensorflow-estimator-2.12.0
  Attempting uninstall: keras
    Found existing installation: keras 2.12.0
    Uninstalling keras-2.12.0:
      Successfully uninstalled keras-2.12.0
  Attempting uninstall: tensorboard
    Found existing installation: tensorboard 2.12.2
    Uninstalling tensorboard-2.12.2:
      Successfully uninstalled tensorboard-2.12.2
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tf-nightly-macos 2.13.0.dev20230417 requires keras<2.13,>=2.12.0rc0, but you have keras 2.13.1 which is incompatible.
tf-nightly-macos 2.13.0.dev20230417 requires tensorboard<2.13,>=2.12, but you have tensorboard 2.13.0 which is incompatible.
tf-nightly-macos 2.13.0.dev20230417 requires tensorflow-estimator<2.13,>=2.12.0rc0, but you have tensorflow-estimator 2.13.0 which is incompatible.
Successfully installed keras-2.13.1 tensorboard-2.13.0 tensorflow-2.13.0 tensorflow-estimator-2.13.0 tensorflow-macos-2.13.0
(base) suryanarayanay-macbookpro:~ suryanarayanay$ python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
(base) suryanarayanay-macbookpro:~ suryanarayanay$ 

``` Hey, 

I installed TensorFlow-metal as well. But ya this looks good. 

I created a new conda env with python 3.9 and installed everything again. Now it is working now. But still not working in the old environment.  @GopikrishnanSasikumar Thank you for the confirmation!
Glad it worked fine for you, closing this issue for now. Thank you! Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61182">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61182">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

tf 2.13

### Custom code

Yes

### OS platform and distribution

MacOS monterey

### Mobile device

_No response_

### Python version

3.8

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

Trying to import tensorflow producing the following error

```bash
TypeError: bases must be types
```

### Standalone code to reproduce the issue

```shell
import tensorflow as tf
```


### Relevant log output

```shell
TypeError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 import tensorflow

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/tensorflow/__init__.py:38
     35 import sys as _sys
     36 import typing as _typing
---> 38 from tensorflow.python.tools import module_util as _module_util
     39 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     41 # Make sure code inside the TensorFlow codebase can use tf2.enabled() at import.

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/tensorflow/python/__init__.py:37
     29 # We aim to keep this file minimal and ideally remove completely.
     30 # If you are adding a new file with @tf_export decorators,
     31 # import it in modules_with_exports.py instead.
     32
     33 # go/tf-wildcard-import
     34 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
     36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
---> 37 from tensorflow.python.eager import context
     39 # pylint: enable=wildcard-import
     40
     41 # Bring in subpackages.
     42 from tensorflow.python import data

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/tensorflow/python/eager/context.py:29
     26 from absl import logging
     27 import numpy as np
---> 29 from tensorflow.core.framework import function_pb2
     30 from tensorflow.core.protobuf import config_pb2
     31 from tensorflow.core.protobuf import rewriter_config_pb2

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/tensorflow/core/framework/function_pb2.py:5
      1 # -*- coding: utf-8 -*-
      2 # Generated by the protocol buffer compiler.  DO NOT EDIT!
      3 # source: tensorflow/core/framework/function.proto
      4 """Generated protocol buffer code."""
----> 5 from google.protobuf.internal import builder as _builder
      6 from google.protobuf import descriptor as _descriptor
      7 from google.protobuf import descriptor_pool as _descriptor_pool

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/google/protobuf/internal/builder.py:42
     40 from google.protobuf.internal import enum_type_wrapper
     41 from google.protobuf import message as _message
---> 42 from google.protobuf import reflection as _reflection
     43 from google.protobuf import symbol_database as _symbol_database
     45 _sym_db = _symbol_database.Default()

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/google/protobuf/reflection.py:51
     33 """Contains a metaclass and helper functions used to create
     34 protocol message classes from Descriptor objects at runtime.
     35
   (...)
     45 this file*.
     46 """
     48 __author__ = 'robinson@google.com (Will Robinson)'
---> 51 from google.protobuf import message_factory
     52 from google.protobuf import symbol_database
     54 # The type of all Message classes.
     55 # Part of the public interface, but normally only used by message factories.

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/google/protobuf/message_factory.py:43
     40 __author__ = 'matthewtoia@google.com (Matt Toia)'
     42 from google.protobuf.internal import api_implementation
---> 43 from google.protobuf import descriptor_pool
     44 from google.protobuf import message
     46 if api_implementation.Type() == 'cpp':

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/google/protobuf/descriptor_pool.py:63
     60 import collections
     61 import warnings
---> 63 from google.protobuf import descriptor
     64 from google.protobuf import descriptor_database
     65 from google.protobuf import text_encoding

File /opt/homebrew/Caskroom/miniforge/base/envs/mlp/lib/python3.8/site-packages/google/protobuf/descriptor.py:47
     45   import binascii
     46   import os
---> 47   from google.protobuf.pyext import _message
     48   _USE_C_DESCRIPTORS = True
     51 class Error(Exception):

TypeError: bases must be types
```
The protobuf version is `3.20.3`
