VSCode中autopep8无法运行问题解决方案(提示Error: Command failed,usage)
作者:mighty13 时间:2022-03-13 22:55:19
错误现象: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,问题解决!
来源:https://blog.csdn.net/mighty13/article/details/109013552
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
在pandas中遍历DataFrame行的实现方法
![](https://img.aspxhome.com/file/2023/7/75867_0s.jpg)
Oracle如何直接运行OS命令(上)第1/2页
常见数据库系统比较 Oracle数据库
利用arcgis的python读取要素的X,Y方法
修改SQL Server 2005 sa用户密码的方法
js换图片效果可进行定时操作
最强大最好最全的javascript 验证表单的例子
Python图像处理之直线和曲线的拟合与绘制【curve_fit()应用】
![](https://img.aspxhome.com/file/2023/3/67353_0s.png)
Python检测网络延迟的代码
citespace数据处理:用python对Ref文档进行去重方式
![](https://img.aspxhome.com/file/2023/4/75954_0s.jpg)
python文件比较示例分享
Django使用中间件解决前后端同源策略问题
![](https://img.aspxhome.com/file/2023/3/71343_0s.png)
Python使用django搭建web开发环境
![](https://img.aspxhome.com/file/2023/9/90699_0s.jpg)
艺术和设计之间的差别
![](https://img.aspxhome.com/file/UploadPic/201011/17/01-13s.jpg)
Mysql5写中文乱码问题解决
python监控文件或目录变化
Python编程mac下使用pycharm小技巧
![](https://img.aspxhome.com/file/2023/9/75119_0s.jpg)