Skip to content

Instantly share code, notes, and snippets.

@john-sandall
Last active May 23, 2020 16:15
Show Gist options
  • Save john-sandall/e5087901018311f7e23099ebe5f4e44f to your computer and use it in GitHub Desktop.
Save john-sandall/e5087901018311f7e23099ebe5f4e44f to your computer and use it in GitHub Desktop.
Fix broken virtualenv symlinks due to brew upgrade
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