解决ImportError: cannot import name ‘OrderedDict’ from ‘typing’错误的方法

from torchvision import datasets, transforms 报了 ImportError: cannot import name 'OrderedDict' from 'typing'的错误

环境是:pytorch:1.13.0

               python :3.7.0

本来代码只有一点导入下载数据集并做处理,准备先运行下载数据集时,报了这个错误。

 

 查询网上说的是python的版本有问题  于是在anconda上更改这个环境的版本到python3.7.2

然后运行再试着运行代码,

运行成功!

总结:这个错误我这里是因为python的版本不兼容导致的,在anconda上面更新环境的python版本可以解决(另在terminal上使用pip更新python会找不到版本不适合用来更新python) 

 在anconda上的更新语法为:(3.7.2为例)

conda install python==3.7.2 -n 要更新环境的名字

物联沃分享整理
物联沃-IOTWORD物联网 » 解决ImportError: cannot import name ‘OrderedDict’ from ‘typing’错误的方法

发表评论