这篇文章给大家分享的是有关vscode中autopep8无法运行怎么办的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。错误现象:autopep8无法运行,运行后vscode右下角提示Error: Command f
这篇文章给大家分享的是有关vscode中autopep8无法运行怎么办的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
错误现象:autopep8无法运行,运行后vscode右下角提示
Error: Command failed: autopep8 c:\Users\Administrator\Desktop\python\第1章 概述\1-10.py usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename] [--ignore-local-config] [-r] [-j n] [-p n] [-a] [--experimental] [--exclude globs] [--list-fixes] [--ignore errors] [--select errors] [--max-line-length n] [--line-range line line] [--hang-closing] [--exit-code] [files [files ...]] autopep8: error: autopep8 only takes one filename as argument unless the "--in-place" or "--diff" args are used
usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename] [--ignore-local-config] [-r] [-j n] [-p n] [-a] [--experimental] [--exclude globs] [--list-fixes] [--ignore errors] [--select errors] [--max-line-length n] [--line-range line line] [--hang-closing] [--exit-code] [files [files ...]] autopep8: error: autopep8 only takes one filename as argument unless the "--in-place" or "--diff" args are used
错误原因 :
文件路径中包含有空格!
问题现象:运行autopep8之后,提示插件正常运行,但是代码没有任何变化。
问题解决过程:
首先在命令行中使用autopep8 文件路径.py进行测试,运行后命令行中显示所有代码,但未格式化文档。
根据运行autopep8的命令帮助以及网络查询可知,autopep8运行时应加上--in-place --aggressive参数
命令格式即为 autopep8 --in-place --aggressive 文件路径名.py
命令行中运行autopep8问题解决!
如何在VSCode中为autopep8增加参数?
尝试在preference>setting中设置autopep8Args,但是无效!
搜索文件找到C:\Users\Administrator\.vscode\extensions\himanoa.Python-autopep8-1.0.2目录,即扩展安装目录。
打开extension.js文件。
找到
exec('autopep8 ' + filename, function(error, stdout, stderr){
将其修改为
exec('autopep8 --in-place --aggressive ' + filename, function(error, stdout, stderr){
重启VSCode,问题解决!
感谢各位的阅读!关于“VSCode中autopep8无法运行怎么办”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
--结束END--
本文标题: VSCode中autopep8无法运行怎么办
本文链接: https://www.lsjlt.com/news/247819.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-02
2024-05-02
2024-05-02
2024-05-02
2024-05-02
2024-05-02
2024-05-02
2024-05-01
2024-05-01
2024-05-01
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0