0
$\begingroup$

I am trying to use tensorflow and keras for one of the tasks but while importing the tensorflow I am getting the below error. Till now I have removed the virtual which I have created previously and then created the new virtual environment again, but still I am getting the same error. Any leads would be appreciated. Here is the command below which I am running.

import tensorflow as tf

Here is the error I am getting

runfile('C:/Users/Lenovo/.spyder-py3/temp.py', wdir='C:/Users/Lenovo/.spyder-py3')
Traceback (most recent call last):

  File "C:\Users\Lenovo\.spyder-py3\temp.py", line 1, in <module>
    import tensorflow as tf

File "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\site-packages\tensorflow__init__.py", line 28, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

  File "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *

  File "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 16, in <module>
    from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2

      File "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\site-packages\tensorflow\core\framework\node_def_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 "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\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 "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\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 "C:\Users\Lenovo\Anaconda3\envs\myenv\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 92, in <module>
__module__ = 'tensorflow.core.framework.resource_handle_pb2'

TypeError: expected bytes, Descriptor found

Below is the configuration of my system.

(myenv) C:\Users\Lenovo>conda list tensorflow
# packages in environment at C:\Users\Lenovo\Anaconda3\envs\myenv:
#
# Name                    Version                   Build  Channel
tensorflow                1.14.0                   pypi_0    pypi
tensorflow-estimator      1.14.0                   pypi_0    pypi

(myenv) C:\Users\Lenovo>conda list keras
# packages in environment at C:\Users\Lenovo\Anaconda3\envs\myenv:
#
# Name                    Version                   Build  Channel
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.0                    pypi_0    pypi

(myenv) C:\Users\Lenovo>
$\endgroup$
2
  • $\begingroup$ I check tensorflow github, and there this issue is explained. Upgrading to 1.15 resolved the issue. check it here - github.com/tensorflow/tensorflow/issues/35208 $\endgroup$ Feb 18, 2020 at 12:43
  • $\begingroup$ @SaandeepSreerambatla I have upgraded the tensorflow to 1.15 but still its not working still showing the same error. I am using tensorflow not tensorflow-gpu. $\endgroup$ Feb 19, 2020 at 5:12

2 Answers 2

1
$\begingroup$

Try this, worked for me:

pip install protobuf-py3
pip install --upgrade protobuf
$\endgroup$
0
$\begingroup$

I resolved the issue by creating new environment with tensorflow by the below two commands:

conda create -n tensorflow_env tensorflow
conda activate tensorflow_env
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.