Python 如何检查是否安装了paho mqtt
我正在运行一个.sh文件,并在其中安装pip和paho mqtt。我正在ubuntu中运行该文件。但当我第二次运行该文件时,pip和paho安装也在进行中。在执行这些谎言之前,我想检查是否安装了这些谎言。有人能帮我吗 我的档案如下:Python 如何检查是否安装了paho mqtt,python,shell,pip,paho,Python,Shell,Pip,Paho,我正在运行一个.sh文件,并在其中安装pip和paho mqtt。我正在ubuntu中运行该文件。但当我第二次运行该文件时,pip和paho安装也在进行中。在执行这些谎言之前,我想检查是否安装了这些谎言。有人能帮我吗 我的档案如下: #install mqtt dependency git clone git://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.python.git cd org.eclipse.paho.mqtt.pytho
#install mqtt dependency
git clone git://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.python.git
cd org.eclipse.paho.mqtt.python
sudo python setup.py install
sudo apt install python-pip
sudo pip install paho-mqtt
我想做的是
if !(check is installed) then
#install mqtt dependency
git clone git://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.python.git
cd org.eclipse.paho.mqtt.python
sudo python setup.py install
sudo apt install python-pip
sudo pip install paho-mqtt
这对我有帮助
s=`dpkg -s python-pip | grep Status`
if [[ $s == *"installed"* ]]; then
#installed
else
git clone git://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.python.git
cd org.eclipse.paho.mqtt.python
sudo python setup.py install
sudo apt install python-pip
fi
可能与我之前在终端中使用的命令重复,它工作正常。但我想知道如何将它添加到.sh文件中,以检查它是否已安装。比如,(如果;那么)