当前位置:网站首页>Error encountered while importing keras typeerror: descriptors cannot not be created directly If this call came from a _
Error encountered while importing keras typeerror: descriptors cannot not be created directly If this call came from a _
2022-06-22 06:29:00 【Work quietly】
Problem description
The version corresponds to
keras And tensorflow Version correspondence :https://master–floydhub-docs.netlify.app/guides/environments/
The version of this paper is : tensorflow 2.2.0 + keras 2.3.0 + python3.7
The version correspondence must be consistent with the table description in the link , Otherwise, it is easy to report an error
The following instructions can be executed in sequence :
conda Revision in China python Version command :conda install python=3.7; Or create a new one conda Environmental Science conda create -n keras python=3.7, Choose one of the two commands to execute .pip install keras==2.3.0 pip install tensorflow==2.2.0
Problem description
In execution import keras The following error occurred while executing the command :
(keras) [email protected]:~/xxxxxx/MatchZoo-master$ python
Python 3.7.13 (default, Mar 29 2022, 02:18:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/keras/backend/__init__.py", line 1, in <module>
from .load_backend import epsilon
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/keras/backend/load_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 53, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import function_pb2 as tensorflow_dot_core_dot_framework_dot_function__pb2
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/core/framework/function_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 42, in <module>
serialized_options=None, file=DESCRIPTOR),
File "/home/work/anaconda3/envs/keras/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 560, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
Problem solving
pip install protobuf~=3.19.0
Successful solution
Then execute again import keras No mistake :
(keras) [email protected]-cli0crch:~/xxxxxx/MatchZoo-master$ python
Python 3.7.13 (default, Mar 29 2022, 02:18:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.
>>> import tensorflow
边栏推荐
猜你喜欢
![[openairinterface5g] RRC NR resolution (I)](/img/04/fec30b5c86f29d82bd7d0b13293494.jpg)
[openairinterface5g] RRC NR resolution (I)
![[technical notes]](/img/5c/3a1fa6326f0bf16da8032526173343.png)
[technical notes]

Four functional interfaces (required)

Research on automatic landing control system of carrier aircraft

5G终端标识SUPI,SUCI及IMSI解析
![Detailed interpretation of tab[i = (n - 1) & hash]](/img/be/3e84b3e8406833c2a235494f1a035f.png)
Detailed interpretation of tab[i = (n - 1) & hash]

Performance comparison and analysis

【5G NR】NAS连接管理—CM状态

SQL injection vulnerability (x) secondary injection

Leetcode the shortest path of three (eight) charts per week
随机推荐
[5g NR] UE registration management status
类加载内存分析
Expert system clips from introduction to mastery (I) introduction and overview of clips
Geoswath plus technology and data acquisition and processing
IO intensive and CPU intensive
Vulnérabilité à l'injection SQL (XIII) injection base64
仙人掌之歌——进军To C直播(1)
C skill tree evaluation - customer first, making excellent products
Swagger common annotation summary
Pytest data parameterization & data driven
ERROR: cannot verify nih.at’s certificate, issued by “/C=US/O=Let‘s Encrypt/CN=R3”,wget报错
Cactus Song - online operation (4)
[openairinterface5g] high level module interface and ITTI entity thread creation
【5G NR】手机身份证号IMEI与IMEISV
leetcode每周3道(八)图之最短路
【5G NR】NG接口
【5G NR】NGAP协议之NG Setup
Lock lock (key)
【5G NR】RRC连接重建解析
CGIC file upload - rookie notes