autopep8 in VSCode can't run problem solution of prompt Error: Command failed usage

  • 2021-09-12 01:39:48
  • OfStack

Error phenomenon: autopep8 can't run, and the lower right corner of vscode prompts after running

Error: Command failed: autopep8 c:\ Users\ Administrator\ Desktop\ Python\ Chapter 1 Overview\ 1-10. py usage: autopep8 [--h] [--version] [--v] [--d] [--global-ES24filename] [--ignore-local-config] [--r] [--ES30n] [--p n] [--experimental] list-fixes] [--ES40errors] [--select errors] [--max-line-length n] [--exit-closing] [--exit-code] [files [files...]] autopep8: error: autopep8 only argument argument argument argument argument argument the "or"--73EN 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

Error cause:

The file path contains spaces!

Resolution of invalid autopep8 plug-in running in VSCode (plug-in running, but not formatting code)

Problem phenomenon: After running autopep8, the plug-in is prompted to work normally, but there is no change in the code.

Problem solving process:

1. First test on the command line using the autopep8 file path. py. After running, all the code is displayed on the command line, but the document is not formatted.

2. According to the command help for running autopep8 and the network query, autopep8 should be run with the--in-place--aggressive parameter

The command format is autopep8--in-place--aggressive file pathname. py

Run autopep8 problem solving on command line!

3. How to add parameters to autopep8 in VSCode?

Try preference > autopep8Args is set in setting, but it is invalid!

Search the file to find the directory C:\ Users\ Administrator\ vscode\ extensions\ himanoa. python-autopep8-1. 0.2, which is the extension installation directory.

Open the extension. js file.

Find


 exec('autopep8 ' + filename, function(error, stdout, stderr){

Modify it to


 exec('autopep8 --in-place --aggressive ' + filename, function(error, stdout, stderr){

Restart VSCode, problem solved!


Related articles: