visual-studio-codepipautopep8

Visual Studio Code is not recogonizing an Autopep8 installation


I use Visual Studio Code for developing in Django. I did all of the following inside a virtual environment.

Whenever I save the Python (.py) files, an alert pops up at the bottom right of the screen telling me: "Formatter autopep8 is not installed. Install?". It gives me three options - "Yes", "Use black, and "Use yapf".

If I click "Yes", it gives me another alert saying that there is no pip installer available in the selected environment. I then tried to go inside the integrated terminal and run pip install autopep8 and it says in the terminal that it was installed successfully. But when I save the Python files, it still gives me the same alert. Check the photo below.


Solution

  • Open your command palette with Shift + āŒ˜ + P. Type in Preferences: Open Workspace Settings. I'll share the settings I use with you, some of which may be of interest:

    {
        "python.pythonPath": "${workspaceFolder}/backend/env/bin/python3",
        "python.venvPath": "${workspaceFolder}/backend/env",
        "python.linting.flake8Enabled": true,
        "python.linting.flake8Path": "flake8",
        "python.linting.flake8Args": ["--ignore", "E501"],
        "python.linting.pylintEnabled": true,
        "python.linting.pylintPath": "pylint",
        "python.linting.pylintArgs": ["--load-plugins", "pylint_django"]
    }
    

    Note that these are the workspace settings and not the user settings. User settings are applied across all of your Visual Studio Code projects.