File size: 731 Bytes
44e905f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import subprocess
import sys

def clean_package(package_name):
    """Force uninstalls a package to ensure a clean state."""
    print(f"Attempting to forcefully uninstall {package_name}...")
    # Use -y to automatically confirm and run command
    result = subprocess.run(
        [sys.executable, "-m", "pip", "uninstall", "-y", package_name],
        capture_output=True,
        text=True
    )
    if result.returncode == 0:
        print(f"Successfully uninstalled {package_name}.")
    else:
        # It's okay if it fails, it might just not be installed.
        print(f"{package_name} not found or uninstall failed, continuing.")

if __name__ == "__main__":
    clean_package("gradio")
    clean_package("gradio_client")