python - how to automatically update pyserial to latesT? -
i have following code raise exception when pyserial version less 2.7,how programatically run pip install pyserial --upgrade
automatically update latest version , ensure installed correctly?
if py_ser_ver < 2.7: raise standarderror("pyserial version 2.7 or greater required. version is: " + serial.version)
use os.system('python -m pip install pyserial --upgrade') or use subprocess
then once installation complete, check using python -m pip list command. work if pip not in path.
import os import subprocess = os.system('python -m pip install pyserial --upgrade') if == 0: d = subprocess.popen('python -m pip list', stdout = subprocess.pipe).communicate() if 'pyserial' in d[0]: print 'success'
Comments
Post a Comment