So this may have been a dumb way of doing it but I wanted to check if pip was installed via a script, so I ran the pip version command and checked if the first 3 characters of the command were "pip" and if so I could say I knew pip was installed. Problem is when I run this and get a command not found
error, the logic still thinks pip is installed. Why is? What is that command not found
error returning? It can't be pip right so why does pip not install? And what's a better way of detecting if pip is installed?
pip=$(sudo /root/.local/bin/pip -V | cut -c 1-3)
if [[ pip != "pip" ]]; then
echo "Installing pip..."
curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py
sudo /workplace/user/package/src/EnvImprovement/bin/python2.7 get-pip.py --user
else
echo "Pip detected."
fi