-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_pip.sh
47 lines (40 loc) · 1.2 KB
/
install_pip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
echo "Checking if pip is already installed..."
if command -v pip3 &>/dev/null; then
echo "pip is already installed"
pip3 --version
exit 0
fi
# Check if python3 is installed
if ! command -v python3 &>/dev/null; then
echo "Python 3 is not installed. Installing Python 3..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
if ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install python3
else
echo "Please install Python 3 manually for your operating system"
exit 1
fi
fi
echo "Downloading get-pip.py..."
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
echo "Installing pip..."
python3 get-pip.py
# Clean up
rm get-pip.py
echo "Verifying pip installation..."
pip3 --version
if [ $? -eq 0 ]; then
echo "pip was successfully installed!"
# Create symlink from pip3 to pip
if [[ "$OSTYPE" == "darwin"* ]]; then
sudo ln -s $(which pip3) /usr/local/bin/pip
echo "Created symlink from pip3 to pip"
fi
else
echo "There was an error installing pip"
fi