Cannot import tensorflow or keras: ordered dict
so OrderedDict is from collections which should be on your pc anyway. it seems like some of python's dependencies are not on your system path. you should double-check check you have everything that needs to be there. I have anaconda\scripts there
if that fails:
try and pip install it (collections) anyway. then try and uninstall Tensorflow and Keras and everything related and then reinstall.
from experience, I can tell you a lot of times this is something you need to do when modifying your Tensorflow installation since the resolver is just horrendous
if it still doesn't work try to get a specific version of Tensorflow that is more stable.
I hope this helps :)
I have python 3.7.0 on windows 11 using vscode. I pip installed tensorflow and keras but when I tried to import them it gave me an error and said cannot import name OrderedDict
Tried uninstalling and reinstalling both tf and keras. Didn’t work
Error Message:
Traceback (most recent call last):
File "c:/Users/Jai K/CS Stuff/test.py", line 1, in 
import tensorflow
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_init_.py", line 37, in 
from tensorflow.python.tools import module_util as module_util
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python_init.py", line 42, in 
from tensorflow.python import data
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\data_init_.py", line 21, in 
from tensorflow.python.data import experimental
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\data\experimental_init_.py", line 96, in 
from tensorflow.python.data.experimental import service
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\data\experimental\service_init_.py", line 419, in 
from tensorflow.python.data.experimental.ops.data_service_ops import distribute
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py", line 25, in 
from tensorflow.python.data.ops import dataset_ops
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 29, in 
from tensorflow.python.data.ops import iterator_ops
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 34, in 
from tensorflow.python.training.saver import BaseSaverBuilder
ne 32, in     from tensorflow.python.checkpoint import checkpoint_management
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\checkpoint_init_.py", line 3, in     from tensorflow.python.checkpoint import checkpoint_view
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\checkpoint\checkpoint_view.py", line 19, in     from tensorflow.python.checkpoint import trackable_view
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\checkpoint\trackable_view.py", line 20, in     from tensorflow.python.trackable import converter
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\trackable\converter.py", line 18, in     from tensorflow.python.eager.polymorphic_function import saved_model_utils
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\polymorphic_function\saved_model_utils.py", line 36, in     from tensorflow.python.trackable import resource
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\trackable\resource.py", line 22, in     from tensorflow.python.eager import def_function
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\def_function.py", line 20, in     from tensorflow.python.eager.polymorphic_function.polymorphic_function import set_dynamic_variable_creation
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\polymorphic_function\polymorphic_function.py", line 76, in     from tensorflow.python.eager.polymorphic_function import function_spec as function_spec_lib
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\polymorphic_function\function_spec.py", line 25, in     from tensorflow.core.function.polymorphism import function_type as function_type_lib
File "C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\core\function\polymorphism\function_type.py", line 19, in     from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, OrderedDict
ImportError: cannot import name 'OrderedDict' from 'typing' (C:\Users\Jai K\AppData\Local\Programs\Python\Python37\lib\typing.py)