ImportError: cannot import name 'OrderedDict' from 'typing' (C:\Users\admin\.conda\envs\shuchuyolo\lib\typing.py)
时间: 2023-09-18 12:07:33 浏览: 688
ImportError:无法从“django.utils.encoding”导入名称“force text”Python 错误
该错误是由于Python和PyTorch版本不一致导致的。PyTorch的torchvision模块需要从typing中导入OrderedDict,但是Python 3.7对应的typing包里没有OrderedDict,所以无法导入导致报错。解决方法是修改报错位置的maxvit.py文件,将从typing中导入OrderedDict的语句改为从typing_extensions中导入。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [ImportError: cannot import name ‘OrderedDict‘ from ‘typing‘ (/root/miniconda3/envs/clip/lib/...)](https://blog.csdn.net/weixin_43656802/article/details/130012263)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [ImportError: cannot import name ‘OrderedDict‘ from ‘typing‘ (D:\environment\Anaconda\envs\DROID\...](https://blog.csdn.net/Elon15/article/details/129710215)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文