Skip to content

Conversation

sbivol
Copy link

@sbivol sbivol commented May 31, 2025

Description

This fixes #2547 for the (default) case when g:black_use_virtualenv = 1.
The fix for g:black_use_virtualenv = 0 is a superset of these changes but is more invasive so I'll create a separate branch for it.

To trigger the bug on Linux:

  • make sure you don't have black installed as a system package: apt purge black
  • launch vim built with Python 3.X
  • run :BlackVersion, let it finish creating the virtualenv, close vim
  • launch vim built with Python 3.Y
  • run :BlackVersion, you should see an error: ModuleNotFoundError: No module named 'black'

I usually encounter this issue when I upgrade to a new Kubuntu release which has a newer Vim built against a newer Python, since I keep the same user data so the old virtualenv created for black is still there.

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

sbivol and others added 3 commits July 11, 2025 03:02
This commit only addresses the `g:black_use_virtualenv = 1` case (which is the default).
Co-authored-by: GiGaGon <[email protected]>
@sbivol sbivol force-pushed the fix/mismatched-pythons branch from edac3b5 to 2229e73 Compare July 11, 2025 02:04
@sbivol
Copy link
Author

sbivol commented Jul 11, 2025

I have rebased the branch, please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin can't find black python module
2 participants