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

Cannot install 'black' formatter for Python in VS22 #7952

Open
vsfeedback opened this issue Jul 16, 2024 · 6 comments
Open

Cannot install 'black' formatter for Python in VS22 #7952

vsfeedback opened this issue Jul 16, 2024 · 6 comments
Assignees
Labels
needs investigation Could be an issue - needs investigation

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
When trying to reformat Python code in Visual Studio 2022 (CTRL + K + D), it shows this pop-up:
image.png

After pressing "Yes", the Output window shows install progress, but after it's done, I still get the same pop-up:
image.png

Changing formatter to something other than 'black' doesn't resolve the issue, I still get stuck in an endless loop.


Original Comments

Feedback Bot on 7/4/2024, 07:18 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@StellaHuang95
Copy link
Contributor

What Python environment are you currently using for your project? My guess is that black might not be installed in your active environment. If you right-click on the selected environment, navigate to Manage Python Packages, and install black from the package management window, does it resolve the error you're encountering?

@Nickelony
Copy link

What Python environment are you currently using for your project? My guess is that black might not be installed in your active environment. If you right-click on the selected environment, navigate to Manage Python Packages, and install black from the package management window, does it resolve the error you're encountering?

My project isn't a VS solution, but just a folder with packages being managed through Poetry. I can confirm that black is installed in my active environment, yet I keep getting that popup every time.

@StellaHuang95 StellaHuang95 added needs investigation Could be an issue - needs investigation and removed waiting for response labels Jul 22, 2024
@TheTruthCooper
Copy link

Poetry_Black_Python_Diagnostics.zip

dunno if this would help matters at all but I think it's a decent start with just these few scripts that can be attached and includes an extremely detailed README alongside a Document for guiding the implementation for a more semi-permanent to permanent diagnostics solution.

@Nickelony
Copy link

Poetry_Black_Python_Diagnostics.zip

dunno if this would help matters at all but I think it's a decent start with just these few scripts that can be attached and includes an extremely detailed README alongside a Document for guiding the implementation for a more semi-permanent to permanent diagnostics solution.

Thank you! I just did some deeper testing and I think I found the reason this is happening.
Basically, our project is a monorepo with multiple Python projects inside, and each one of them has their own venv directory.
I switch virtual environments every time I work on another project within that monorepo to match the given venv. since each of those projects has their own packages installed.
I can't 100% confirm this right now, as I'm out of office, but could it be possible that Visual Studio tried to find black in the root of the monorepo instead of the selected venv?
Before doing some more testing, I uninstalled everything Python from my machine and reinstalled only what's necessary, then opened only one of the projects within that monorepo and the black formatter started working.
Before the uninstall, I also had Anaconda installed, but I'm not sure if that would make a difference.

@TheTruthCooper
Copy link

TheTruthCooper commented Aug 13, 2024 via email

@TheTruthCooper
Copy link

TheTruthCooper commented Aug 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Could be an issue - needs investigation
Projects
None yet
Development

No branches or pull requests

5 participants