Windows下python37安装tensorflow后,import时发生错误:
python
import tensorflow as tf
报以下错误:
shell
D:\xxxx\Python37\lib\site-packages\tensorflow\core\function\polymorphism\function_type.py in <module>
17 import collections
18 import inspect
---> 19 from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, OrderedDict
20
21 from tensorflow.core.function import trace_type
ImportError: cannot import name 'OrderedDict' from 'typing' (D:xxxx\Python37\lib\typing.py)
解决办法:
修改文件:Python37\lib\site-packages\tensorflow\core\function\polymorphism\function_type.py
python
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple #OrderedDict
from typing_extensions import OrderedDict