Search code examples
pythonvisual-studio-codeautopep8

Autopep8 not appearing in Command Palette in VS Code despite being installed and accessible in the terminal


In VS Code, I have installed autopep8 and verified that the path is correct. I can use autopep8 in the terminal without any issues. However, when I search for the "python run" item in the Command Palette, I see all the other options from the extension except autopep8.

I have attempted to change the path of autopep8 to use the version installed in my machine's Python installation, but that didn't resolve the issue.


Solution

  • You can search Python.Formatting.Provider in settings and choose autopep8:

    enter image description here

    Or you can add the following codes to your settings.json:

    "python.formatting.provider": "autopep8",
    

    When you want to use format function, you can use shortcuts "Ctrl+Shift+P" and search "Format Document".

    BTW, I suggest you add the following codes to your settings.json as well:

      "editor.formatOnPaste": true,
      "editor.formatOnSave": true,
      "editor.formatOnType": true,