当前位置:网站首页>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
边栏推荐
- 5g terminal identification Supi, suci and IMSI analysis
- 【5G NR】NG接口
- Upload file prompt 413 request entity too large error
- -bash: telnet: command not found的解决方法
- ERROR: cannot verify nih. At's certificate, issued by "/c=us/o=let's encrypt/cn=r3", WGet reports an error
- 仙人掌之歌——进军To C直播(1)
- Markdown中插入类图(classDiagram)
- CGIC file upload - rookie notes
- 【M32】单片机 xxx.map 文件简单解读
- Little bear school bearpi HM micro officially integrated into openharmony trunk
猜你喜欢

SQL 注入漏洞(十三)base64注入

Configuration files required for SSM integration and error reports caused by common configuration errors

KV260的PMOD接口介绍

Research on dynamics and control of single ball robot

Callable

ForkJoinPool

Usage of trim, ltrim and rtrim functions of Oracle

用蒙特卡洛法求圆周率pi

【5G NR】UE注册管理状态

Huiding technology gr551x series development board supports openharmony
随机推荐
Detailed explanation of eight locks
Performance comparison and analysis
Callable
仙人掌之歌——进军To C直播(2)
【OpenAirInterface5g】RRC NR解析之RrcSetupRequest
SQL injection vulnerability (XIII) Base64 injection
tab[i = (n - 1) & hash] 的详细解读
[PHP] composer 安装
CGIC文件上传----菜鸟笔记
仙人掌之歌——进军To C直播(1)
[PHP]TP6 CLI模式下创建tp6和多应用配置以及常见问题
PgSQL batch insert
Upload file prompt 413 request entity too large error
Swagger common annotation summary
Producer and consumer issues
leetcode每周3道(八)图之最短路
Reflection operation annotation
linux 链接sqlserver,离线安装
Usage of trim, ltrim and rtrim functions of Oracle
Cmake entry level syntax