Created
July 4, 2024 12:17
-
-
Save arcturus10/4edb460f44c4dc804ac6be2843712451 to your computer and use it in GitHub Desktop.
Interactive Pip (Pip2)
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 subprocess | |
from rich import print as Format | |
def install_package(package): | |
package_name = package | |
result = subprocess.run(["pip", "install", package_name]) | |
print(result) | |
def remove_package(package): | |
package_name = package | |
result = subprocess.run(["pip", "uninstall", package_name]) | |
print(result) | |
def details(package): | |
package_name = package | |
#Convert to a String (no 'CompletedProcess' object) | |
original_string = str(subprocess.run(["pip", "show", package_name])) | |
lines = original_string.strip().split("\n") | |
trimmed = "\n".join(lines[:-1]) | |
Format(trimmed) | |
pkg = input("Package Name:") | |
Choices = int(input("1. Install |2.Uninstall |3.Package Info -> ")) | |
if(Choices == 1): | |
install_package(pkg) | |
elif(Choices == 2): | |
remove_package(pkg) | |
elif(Choices == 3): | |
details(pkg) | |
else: | |
Format("Choose Between 1 Install, 2 Uninstall or 3 Info.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment