install pip(mac)

simple method:  sudo easy_install pip

      you have done!and can install the other py programs using pip

eg.  sudo pip install openpyxl

the other method:    open  https://pip.pypa.io/en/stable/installing/

   know that https://bootstrap.pypa.io/get-pip.py is the url of pip file

console: curl https://bootstrap.pypa.io/get-pip.py > get-pip.py

console: sudo python get-pip.py 

done!

 

 

在脚本中判断是否安装某模块

if sys.modules.get('openpyxl') is not None:

    import openpyxl

else:

  xxxx

 

在脚本中执行控制台命令

os.system('sudo easy_install pip')

os.system("echo 'value=0' > /tmp/test/testmodule.py") #将testmodule.py中的代码改为"value = 0"  

 

 

原文地址:https://www.cnblogs.com/pengyingh/p/5212681.html