Search code examples
pythonvisual-studio-codewindows-subsystem-for-linuxautopep8

Trying to get autopep8 installed globally on VSCode, Windows WSL2


I have this package installed, but it doesn't have that green start on the top left. When I format a document, it says autopep8 is not installed and would you like to install it. I hit yes, and it says it can't find the file C:/Users/User/AppData/Local/Programs/Python/Python38-32/python.exe: no such file or directory.

How do I fix this. I read I need to add a path, but I don't know where or how. I'm new to VSCode and WSL2. If I run pip3 list on my WSL2 Ubuntu 20.04 it says I have autopep8 1.5.4. But I can't format python documents.


Solution

    1. Please check if Python is available. Enter "where python" in the 'cmd' window:

      enter image description here

    2. Please install and use the latest version of the Python extension in VSCode extension store.

    3. Please install the module "autopep8" in the currently selected VSCode environment.

      Check the source of the installation tool pip, it determines where the module is stored:

      enter image description here

      Check the installation package: "pip show autopep8":

      enter image description here

    Result:

    enter image description here

    For more information about the use of Python in VSCode, you could refer to: Python in VSCode.