Skip to content

Fix handling of mismatched Python version in virtualenv #4675

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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 added 2 commits May 31, 2025 02:10
This commit only addresses the `g:black_use_virtualenv = 1` case (which is the default).
Co-authored-by: GiGaGon <[email protected]>
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