def os_type(win=None,linux=None,Mac=None):
platform = __import__('platform').system().lower()
if platform == 'windows':
print("windows")
return win
elif platform == 'linux':
print("linux")
return linux
elif platform == 'darwin':
print("Mac OS")
return Mac
def pip3install(packge=None, keyword='清华',cmd = 'pip'):
cmd = os_type(win='pip',linux='pip3',Mac='pip3')
if packge == None:
return 'please input you packge name'
else:
source = {'阿里':' -i https://mirrors.aliyun.com/pypi/simple'
,'清华':' -i https://pypi.tuna.tsinghua.edu.cn/simple/'
,'中科大':' -i https://pypi.mirrors.ustc.edu.cn/simple/'
,'华中理工大':' -i http://pypi.hustunique.com/'
,'山东理工大':' -i http: // pypi.sdutlinux.org /'
,'豆瓣':' -i http://pypi.douban.com/simple/'}
__import__('os').system(cmd + ' install ' + str(packge) + source[keyword])
pip3install('pyopenssl','中科大')
懒人换源脚本
最新推荐文章于 2024-08-25 21:21:27 发布