Linux/windows-cmd 运行py文件报错:Error while finding module specification for ‘xxx.py’ (ModuleNotFoundError: __path__ attribute not found on ‘xxx’ while trying to find ‘xxxx.py’)

内容纲要

Linux 运行py文件报错:Error while finding module specification for 'xxx.py' (ModuleNotFoundError: __path__ attribute not found on 'xxx' while trying to find 'xxxx.py')

如上面的命令所示,Python -m指的是把这个.py文件当做模块运行,但如果你一不小心加了.py这个后缀,就会出现这个错误。

其实你要么把"-m"删除,要么删除".py"后缀,问题就迎刃而解了