skip to Main Content

In Visual Studio Code, all formatter extensions for Python are failing to format my .py files. Message is "Skipping standard library file".

I understand that formatters built into Python are no longer supported and I have installed separate formatter extensions autopep8, Black Formatter, Ruff

I also understand that the formatter will not work if the Python interpreter cannot be determined. I had uninstalled and re-installed Python in a different location and the Python version wasn’t showing in the status bar. I have now selected the Python interpreter location and the version is correctly showing in the VS Code status bar. See this question

I also understand that there is an issue where project files are saved within the virtual environment. However, I believe I’ve correctly separated my project code from my virtual environment (env and project code are in peer folders) (See below and this question)

Currently I have

Using the context menu for the file and selecting "Format Document with" then each formatter in turn, I’ve then viewed the Output for that formatter. All report "Skipping standard library file", so this must be a VS Code issue, or a misunderstanding on my part with setting up the Virtual Environment, however I have separate folders for

  • Python (hovering over the Python version in the VS code status bar shows correct location)
  • Python Dev Env
  • Python Django Projects (completely separate form the virtual environment)

I’m less than a week into learning Python/Django, so maybe I’ve missed something basic along the way in relation to virtual environment setup that’s causing VS Code to believe my project file is a standard library file?

2

Answers


  1. Chosen as BEST ANSWER

    This is not ideal, but if all else fails try the "nuclear" option: Uninstall and reinstall Python, Visual Studio Code with required extensions. Delete and recreate the virtual environment and reinstall any project dependencies. Ensure project files are not located in the Python installation folder or the virtual environment.


  2. You can add the following codes to your settings.json:

    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter", 
    },
    

    You can also right-click in your script and choose Format Document With… to set the formatter.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search