重装系统后安装了vscode,在跑以前的pytorch代码(在pycharm中运行依然无错)时一直这样报错[pylint]Module 'torch' has no 'max' member`,搜索一番后,找到关于torch无法识别from_numpy的问题所在

Pylint isn’t picking up that torch has the member function from_numpy. It’s because torch.from_numpy is actually torch._C.from_numpy as far as Pylint is concerned.

最初有三个地方报错

按照torch._C.max修改后,就少了一个

每个都修改不现实,问题可能出在pylint,于是
pip install pylint
依然不行
有可能是vscode编译环境的问题,于是在插件商店中寻找python相关的插件,无果

添加torch到白名单也试过,照样报错
最终在用户设置中添加pylintpath解决了问题
"python.linting.pylintPath":"C:\Users\ROD\Anaconda3\pkgs\pylint-1.8.4-py36_0\Scripts\pylint"

文章来源于互联网,如有雷同请联系站长删除:vscode中pytorch报错[pylint]Module ‘torch’ has no ‘max’ member

发表评论