# Tensorflow import error

**URL:** <https://forum.anaconda.com/t/tensorflow-import-error/48257>\
**Category:** Technical Topics\
**Created:** [January 3, 2023, 12:20pm UTC](https://forum.anaconda.com/t/tensorflow-import-error/48257 "2023-01-03T12:20:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paramveer.prm](https://avatars.discourse-cdn.com/v4/letter/p/f5a800/32.png) [@paramveer.prm](https://forum.anaconda.com/u/paramveer.prm)\
**Post date:** [January 3, 2023, 12:20pm UTC](https://forum.anaconda.com/t/tensorflow-import-error/48257/1 "2023-01-03T12:20:26Z")

</div>

![image](https://europe1.discourse-cdn.com/anaconda/original/2X/d/dd9cb6eda1852ef82976b7632ac86ad58e097113.png)

---

<div class="post-metadata">

**Author:** ![mccoy](https://avatars.discourse-cdn.com/v4/letter/m/f5a800/32.png) [@mccoy](https://forum.anaconda.com/u/mccoy)\
**Post date:** [January 4, 2023, 2:54pm UTC](https://forum.anaconda.com/t/tensorflow-import-error/48257/2 "2023-01-04T14:54:12Z")

</div>

I’ve had the same error when I attempt to import Tensorflow.

---

<div class="post-metadata">

**Author:** ![paramveer.prm](https://avatars.discourse-cdn.com/v4/letter/p/f5a800/32.png) [@paramveer.prm](https://forum.anaconda.com/u/paramveer.prm)\
**Post date:** [January 9, 2023, 10:37am UTC](https://forum.anaconda.com/t/tensorflow-import-error/48257/3 "2023-01-09T10:37:39Z")

</div>

I fixed the error by installing all the packing again in a new environment. Try to install Tensorflow by using the command:- Conda install -c conda-forge Tensorflow

---

<div class="post-metadata">

**Author:** ![mccoy](https://avatars.discourse-cdn.com/v4/letter/m/f5a800/32.png) [@mccoy](https://forum.anaconda.com/u/mccoy)\
**Post date:** [January 9, 2023, 12:51pm UTC](https://forum.anaconda.com/t/tensorflow-import-error/48257/4 "2023-01-09T12:51:14Z")

</div>

I tried that command and am still getting the same error.

---

<div class="post-metadata">

**Author:** ![mccoy](https://avatars.discourse-cdn.com/v4/letter/m/f5a800/32.png) [@mccoy](https://forum.anaconda.com/u/mccoy)\
**Post date:** [January 11, 2023, 3:16pm UTC](https://forum.anaconda.com/t/tensorflow-import-error/48257/5 "2023-01-11T15:16:47Z")

</div>

## Still getting an error message when attempting to import tensor flow. Suggestions?

TypeError Traceback (most recent call last)  
~\AppData\Local\Temp\ipykernel\_21392\4294963926.py in   
----\> 1 import tensorflow

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\__init_\_.py in   
39 import sys as \_sys  
40  
—\> 41 from tensorflow.python.tools import module\_util as \_module\_util  
42 from tensorflow.python.util.lazy\_loader import LazyLoader as \_LazyLoader  
43

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\python\__init_\_.py in   
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top  
39  
—\> 40 from tensorflow.python.eager import context  
41 from tensorflow.python import pywrap\_tensorflow as \_pywrap\_tensorflow  
42

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\python\eager\context.py in   
30 import six  
31  
—\> 32 from tensorflow.core.framework import function\_pb2  
33 from tensorflow.core.protobuf import config\_pb2  
34 from tensorflow.core.protobuf import rewriter\_config\_pb2

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\core\framework\function\_pb2.py in   
14  
15  
—\> 16 from tensorflow.core.framework import attr\_value\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_attr\_\_value\_\_pb2  
17 from tensorflow.core.framework import node\_def\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_node\_\_def\_\_pb2  
18 from tensorflow.core.framework import op\_def\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_op\_\_def\_\_pb2

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\core\framework\attr\_value\_pb2.py in   
14  
15  
—\> 16 from tensorflow.core.framework import tensor\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_tensor\_\_pb2  
17 from tensorflow.core.framework import tensor\_shape\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_tensor\_\_shape\_\_pb2  
18 from tensorflow.core.framework import types\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_types\_\_pb2

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\core\framework\tensor\_pb2.py in   
14  
15  
—\> 16 from tensorflow.core.framework import resource\_handle\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_resource\_\_handle\_\_pb2  
17 from tensorflow.core.framework import tensor\_shape\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_tensor\_\_shape\_\_pb2  
18 from tensorflow.core.framework import types\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_types\_\_pb2

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\core\framework\resource\_handle\_pb2.py in   
14  
15  
—\> 16 from tensorflow.core.framework import tensor\_shape\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_tensor\_\_shape\_\_pb2  
17 from tensorflow.core.framework import types\_pb2 as tensorflow\_dot\_core\_dot\_framework\_dot\_types\_\_pb2  
18

~\AppData\Roaming\Python\Python39\site-packages\tensorflow\core\framework\tensor\_shape\_pb2.py in   
34 containing\_type=None,  
35 fields=[  
—\> 36 \_descriptor.FieldDescriptor(  
37 name=‘size’, full\_name=‘tensorflow.TensorShapeProto.Dim.size’, index=0,  
38 number=1, type=3, cpp\_type=2, label=1,

~\AppData\Roaming\Python\Python39\site-packages\google\protobuf\descriptor.py in **new** (cls, name, full\_name, index, number, type, cpp\_type, label, default\_value, message\_type, enum\_type, containing\_type, is\_extension, extension\_scope, options, serialized\_options, has\_default\_value, containing\_oneof, json\_name, file, create\_key)  
558 has\_default\_value=True, containing\_oneof=None, json\_name=None,  
559 file=None, create\_key=None): # pylint: disable=redefined-builtin  
 → 560 \_message.Message.\_CheckCalledFromGeneratedFile()  
561 if is\_extension:  
562 return \_message.default\_pool.FindExtensionByName(full\_name)

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).

More information: [Changes announced May 6, 2022 | Protocol Buffers Documentation](https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates)
