欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

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

时间:2022-02-02 09:34:44|栏目:Python代码|点击:

错误现象: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,问题解决!

上一篇:Python调用ctypes使用C函数printf的方法

栏    目:Python代码

下一篇:使用PDB简单调试Python程序简明指南

本文标题:VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)

本文地址:http://www.codeinn.net/misctech/192123.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有