Last active
May 23, 2020 16:15
-
-
Save john-sandall/e5087901018311f7e23099ebe5f4e44f to your computer and use it in GitHub Desktop.
Fix broken virtualenv symlinks due to brew upgrade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
from pathlib import Path | |
path = Path("/Users/john/.virtualenvs") | |
list_subfolders_with_paths = [f.path for f in os.scandir(path) if f.is_dir()] | |
for folder in list_subfolders_with_paths: | |
virtualenv_name = folder.split("/")[-1] | |
print(f"🛠 Fixing {virtualenv_name}") | |
subprocess.run(["find", folder, "-type", "l", "-delete"]) | |
subprocess.run(["virtualenv", virtualenv_name]) | |
print("🎉 All broken virtualenv symlinks are fixed!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment