import tensorflow出现了问题:Descriptors cannot be created directly的原因可能是您使用的protobuf包的版本过高,与tensorflow或其他包不兼容¹²³。您可以尝试以下方法来解决这个问题:
- 降级protobuf包的版本,使用pip install protobuf==3.20.*或者conda install protobuf=3.20.*来安装一个较低的版本¹²。
- 设置环境变量PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python,这样会使用纯Python解析,但可能会降低性能¹²。
(1) Tensorflow TypeError: Descriptors cannot be created directly. https://stackoverflow.com/questions/72483283/tensorflow-typeerror-descriptors-cannot-be-created-directly.
(2) TypeError: Descriptors cannot not be created directly. https://stackoverflow.com/questions/72441758/typeerror-descriptors-cannot-not-be-created-directly.
(3) Cannot import tensorflow after latest tensorboard release … https://github.com/tensorflow/tensorflow/issues/59665.