VSCode中autopep8無法運行問題解決方案(提示Error: Command failed,usage)
錯誤現(xiàn)象: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插件運行無效問題解決(插件運行,但不格式化代碼)
問題現(xiàn)象:運行autopep8之后,提示插件正常運行,但是代碼沒有任何變化。
問題解決過程:
1.首先在命令行中使用autopep8 文件路徑.py進行測試,運行后命令行中顯示所有代碼,但未格式化文檔。
2.根據(jù)運行autopep8的命令幫助以及網(wǎng)絡(luò)查詢可知,autopep8運行時應(yīng)加上--in-place --aggressive參數(shù)
命令格式即為 autopep8 --in-place --aggressive 文件路徑名.py
命令行中運行autopep8問題解決!
3.如何在VSCode中為autopep8增加參數(shù)?
嘗試在preference>setting中設(shè)置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,問題解決!
到此這篇關(guān)于VSCode中autopep8無法運行問題解決方案(提示Error: Command failed,usage)的文章就介紹到這了,更多相關(guān)VSCode autopep8無法運行內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python與mysql數(shù)據(jù)庫交互的實現(xiàn)
這篇文章主要介紹了python與mysql數(shù)據(jù)庫交互的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-01-01Python使用os.listdir和os.walk獲取文件路徑
這篇文章主要介紹了Python使用os.listdir和os.walk獲取文件路徑,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-05-05win10+anaconda安裝yolov5的方法及問題解決方案
這篇文章主要介紹了win10+anaconda安裝yolov5的方法及問題解決方案,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-04-04在django中查詢獲取數(shù)據(jù),get, filter,all(),values()操作
這篇文章主要介紹了在django中查詢獲取數(shù)據(jù),get, filter,all(),values()操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08Python實現(xiàn)視頻字幕時間軸格式轉(zhuǎn)換的示例
本文主要介紹了Python實現(xiàn)視頻字幕時間軸格式轉(zhuǎn)換的示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-11-11