使用autopep8无法检查Python文件:AttributeError报错求助
解决autopep8与pycodestyle版本兼容导致的AttributeError问题
你遇到的错误根源是autopep8 2.0.2和pycodestyle 2.11.0版本不兼容:pycodestyle 2.11.0移除了missing_whitespace_around_operator这个函数接口,改用whitespace_around_operator,但旧版autopep8仍在调用旧的函数名,从而触发AttributeError。
以下是两种可行的解决办法:
方法1:升级autopep8到兼容版本
直接将autopep8升级到支持pycodestyle 2.11.0的版本(如2.1.0及以上),执行命令:
pip install --upgrade autopep8
升级完成后重新运行autopep8即可恢复正常。
方法2:降级pycodestyle到适配版本
如果不想升级autopep8,可将pycodestyle降级到2.10.0版本(该版本保留了missing_whitespace_around_operator函数):
pip install pycodestyle==2.10.0
内容的提问来源于stack exchange,提问作者Andrei Lupuleasa
相关产品推荐
相关产品推荐

