ImportError: cannot import name 'OrderedDict' from 'typing' (D:\Python3.7.0\lib\typing.py)
时间: 2024-05-05 12:15:12 浏览: 521
ImportError:无法从“django.utils.encoding”导入名称“force text”Python 错误
This error occurs when the `OrderedDict` class is not found in the `typing` module. This usually happens when you are using an older version of Python that doesn't include the `OrderedDict` class in the `typing` module.
To resolve this error, you should upgrade your Python version to a newer version that includes the `OrderedDict` class in the `typing` module. Alternatively, you can import the `OrderedDict` class directly from the `collections` module instead of the `typing` module.
You can do this by changing your import statement from:
```
from typing import OrderedDict
```
to:
```
from collections import OrderedDict
```
This should resolve the `ImportError` and allow you to use the `OrderedDict` class in your code.
阅读全文