您当前的位置:首页 > IT编程 > python
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)

51自学网 2021-10-30 22:53:46
  python
这篇教程VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)写得很实用,希望能帮到您。

错误现象: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

错误原因 :

文件路径中包含有空格!

VSCode中autopep8插件运行无效问题解决(插件运行,但不格式化代码)

问题现象:运行autopep8之后,提示插件正常运行,但是代码没有任何变化。

问题解决过程:

1.首先在命令行中使用autopep8 文件路径.py进行测试,运行后命令行中显示所有代码,但未格式化文档。

2.根据运行autopep8的命令帮助以及网络查询可知,autopep8运行时应加上--in-place --aggressive参数

命令格式即为 autopep8 --in-place --aggressive 文件路径名.py

命令行中运行autopep8问题解决!

3.如何在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无法运行问题解决方案(提示Error: Command failed,usage)的文章就介绍到这了,更多相关VSCode autopep8无法运行内容请搜索51zixue.net以前的文章或继续浏览下面的相关文章希望大家以后多多支持51zixue.net!


python 基于pygame实现俄罗斯方块
Python实现我的世界小游戏源代码
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。