Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python There is no formatter for 'python' files installed. #22412

Closed
ponponon opened this issue Nov 2, 2023 · 23 comments
Closed

python There is no formatter for 'python' files installed. #22412

ponponon opened this issue Nov 2, 2023 · 23 comments
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@ponponon
Copy link

ponponon commented Nov 2, 2023

图片 图片 图片 图片

The latest vscode causes python's formatting buttons to disappear, even though I have all the relevant python plugins and autopep8 installed!

@Gaotianhong
Copy link

the same question to you

@vscodenpa vscodenpa added the triage-needed Needs assignment to the proper sub-team label Nov 2, 2023
@portrik
Copy link

portrik commented Nov 2, 2023

The same has happened to me. None of the Python formatters, e.g. pylint or Ruff, are recognized as Python formatters.

The only change to my setup was the upgrade of VS Code. No extensions were added, removed or modified.

@roblourens roblourens assigned jrieken and unassigned roblourens Nov 2, 2023
@vscodenpa vscodenpa removed the triage-needed Needs assignment to the proper sub-team label Nov 2, 2023
@ycrouin
Copy link

ycrouin commented Nov 2, 2023

Same here. In the meantime, I downgraded the Python extension from v2023.20.0 to v2023.18.0 and it fixed the issue for me.
Screenshot from 2023-11-02 15-50-03

@tanzeyy
Copy link

tanzeyy commented Nov 2, 2023

Same here. In the meantime, I downgraded the Python extension from v2023.20.0 to v2023.18.0 and it fixed the issue for me. Screenshot from 2023-11-02 15-50-03

Works for me, thanks!

@karthiknadig karthiknadig transferred this issue from microsoft/vscode Nov 2, 2023
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 2, 2023
@karthiknadig
Copy link
Member

These features are moved to their own extensions. See here for more details:
https://code.visualstudio.com/docs/python/formatting#_choose-a-formatter

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
@portrik
Copy link

portrik commented Nov 2, 2023

But none of those extensions are being detected as formatters by VS Code after upgrading to the latest Python extension version.

I have both Ruff and Pylint extensions installed. And I still get the message that I have no formatters installed.

@karthiknadig
Copy link
Member

karthiknadig commented Nov 2, 2023

@portrik Pylint is not a formatter. Install "Black Formatter" extension, or "autopep8" extension. and set this in your settings:

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

If you want to use Ruff then you have to set:

"[python]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "charliermarsh.ruff"
}

If that is not working, then look the Output > Black Formatter or Output > Ruff for details on what went wrong.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 2, 2023
@FPLIsLife
Copy link

But none of those extensions are being detected as formatters by VS Code after upgrading to the latest Python extension version.

I have both Ruff and Pylint extensions installed. And I still get the message that I have no formatters installed.

did you figure this out? i'm having the same issue - "There is no formatter for 'python' files installed."

@nahanoo
Copy link

nahanoo commented Nov 29, 2023

Hi,

If you search for autopep8 and install this formatter it will work.

I think this was solved in a unfortunate way, because people who just had the Python extension installed, suddenly didn't have a working formatting function anymore because it was removed from the Python extension.
Furthermore, clicking "Install formatter" points you to the Python extension which is misleading.

@firstC99
Copy link

firstC99 commented Dec 5, 2023

Also appearing simultaneously is "Connection to server got closed. Server will not be restarted."

After uninstalling Winfsp and all VC++and restarting VScode, everything worked properly.

@PulkitRustagi
Copy link

Search for autopep8 in the extension search bar in VS code and install it (or uninstall and install again if already installed), that should fix the formatter. Test it with ctrl+shift+I on your python scripts.

@kernelplv
Copy link

The problem is not solved for yapf… I am using ssh and python3.6.8.

@shaded-blue
Copy link

Hi,

If you search for autopep8 and install this formatter it will work.

I think this was solved in a unfortunate way, because people who just had the Python extension installed, suddenly didn't have a working formatting function anymore because it was removed from the Python extension. Furthermore, clicking "Install formatter" points you to the Python extension which is misleading.

This was the answer for me. You need Python + autopeop8/Black; the Python listing is very misleading.

@ThePrankMonkey
Copy link

Yeah, installing ms-python.black-formatter worked while searching for the extension in the gui lead me to install mikoz.black-py which kept causing save conflicts.

@bichuga
Copy link

bichuga commented Dec 28, 2023

Does flake8 work as a formatter? It's not listed in https://code.visualstudio.com/docs/python/formatting#_choose-a-formatter and even though I have flake8 extension installed it says

There is no formatter for 'python' files installed.

@DuaneNielsen
Copy link

This is the actual bug I think...
image
If python extension is no longer going to format code, it should not claim to format code!

@andelf
Copy link

andelf commented Jan 15, 2024

Without googling "no formatter for 'python'" and finding this issue, I'd never know I needed to install a new extension.

@nrxM7
Copy link

nrxM7 commented Jan 31, 2024

still having this problem. Formatting doesnt work at all.

@karthiknadig
Copy link
Member

karthiknadig commented Jan 31, 2024

@nrxM7 You need to install the formatter you want from the extension marketplace here are some common choices:

There is no python formatter, you have to pick one.

An update on this issue. We are looking into what can be done about search in the marketplace for this. Python extension itself doesn't register as a formatter. Doing that would block integrations with external providers like Ruff, uFmt, etc. We are investigating if anything can be done to direct users to marketplace in this case. The changes however are outside of this extension, hence we are keeping this closed.

@nrxM7
Copy link

nrxM7 commented Feb 1, 2024

My problem is that no formatter helps, i've tried all of the listed ones but they dont do anything for some reason. Formatting in HTML with Prettier seems to work just fine, but nothing works in Python.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 1, 2024
@karthiknadig
Copy link
Member

@nrxM7 Let us debug this. Install the Black formatter Extension, after you install you should see this log:
image

That log will also tell you if something is not working. If you don't see any errors there then trigger Foramtting using "Format Document with..."
image

It should show you something like this:
image

Make sure you don't have ms-python.python set as default formatter somewhere. It should be ms-python.black-formatter if you are using black.

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

Other formatters have similar logs and similar settings.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 1, 2024
@nrxM7
Copy link

nrxM7 commented Feb 2, 2024

@karthiknadig
Thank you, i don't really know what i did different this time but it worked. Appreciate your help :)

@JonathanDotCel
Copy link

JonathanDotCel commented Feb 22, 2024

TLDR: use autopep8 for formatting and save yourself the stress of wrestling with plugins


Original message:

Still getting this issue. The "Python extension for Visual Studio Code" extension is listed under formatters and claims support. Formatting has worked previously on the same install.

I was missing the "Format Document with..." option, it just would not show up in the context menu or palette.

After installing "Black Formatter", the message has changed to

"Extension 'Prettier - Code formatter' is configured as a formatter but it cannot format 'Python'-files.
Where was this message before?

Anyway, black formatter eventually started working after a restart, thanks.

TBH I've had nothing but issues with the last few releases of VSCode when it comes to formatters (often requiring deliberate version regressions). I suspect this is an issue with VSCode rather than all of the various failing formatters?
(New win10 install, new vscode install, fully patched, etc)


Edit:

Black is far too aggressive, e.g. not breaking very long dictionary lines into smaller chunks.

I can't get ms-python.python to show up at all as a formatter unless I go back over 6 months of older versions.
At that point formatting doesn't work anyway.

Bit sick of doing this with every broken formatter at this point.

2023.12 doesn't show up
2023.10 doesn't format

Can we re-open this issue or at least put more pressure on the core VSCode team to actually fix this?


Edit Edit:
autopep8 works well, and seems to value readability

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests