zoukankan      html  css  js  c++  java
  • Linux安装python环境脚本

    自动安装python环境的脚本

    1.首先判断是不是root用户

    2.判断是否安装

    3.是否下载成功(网络可能有问题)

    4.是否解压成功(文件下载可能缺少)

    5.安装配置python环境

    # coding=utf-8
    
    import os
    import sys
    
    if os.getuid()==0:
        pass
    else:
        print "当前用户不是root用户,请登录root用户执行脚本"
        sys.exit(1)
    
    version = raw_input('是否安装python版本3.5?(y/n)')
    if version == 'y':
        url = 'https://www.python.org/ftp/python/3.5.7/Python-3.5.7.tgz'
    else:
        print '退出程序'
        sys.exit(1)
    
    cmd = 'wget '+url
    res = os.system(cmd)
    if res != 0:
        print '下载源码包失败,请检查网络'
        sys.exit(1)
    
    package_name = 'Python-3.5.7'
    
    cmd = 'tar xf '+package_name+'.tgz'
    res = os.system(cmd)
    if res != 0:
        os.system('rm '+package_name+'.tgz')
        print '解压源码包失败,请重新运行这个脚本'
        sys.exit(1)
    
    cmd = 'cd '+package_name+'&& ./configure --prefix=/usr/local/python && make && make install'
    res = os.system(cmd)
    if res !=0:
        print '编译python源码失败,请检查是否缺少依赖库'
        sys.exit(1)
    
    
  • 相关阅读:
    2013面试C++小结
    Linux C 面试题总结 .
    [SCOI2011]糖果
    python——简单爬虫
    python——ADSL拨号程序
    python——处理xls表格
    Vsphere初试——架设Panabit行为管理
    Vsphere初试——使用Vsphere client
    Vsphere初试——基本安装
    Python2与Python3的不同点
  • 原文地址:https://www.cnblogs.com/zx125/p/11582066.html
Copyright © 2011-2022 走看看