码迷,mamicode.com
首页 > 编程语言 > 详细

Centos7安装Python3.5

时间:2017-10-29 00:41:58      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:sqli   centos7安装   下载   /usr   readline   print   nbsp   class   enable   

1. 安装Python的依赖包

yum -y groupinstall "Development tools"
yum -y install openssl-devel sqlite-devel bzip2-devel ncurses-devel gdbm-devel readline-devel tcl-devel tk-devel xz-devel zlib-devel db4-devel libpcap-devel

2. 下载Python3.5的源码包并编译

cd /usr/local/src
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar -zxf /usr/local/src/Python-3.5.1.tgz && cd Python-3.5.1
./configure --prefix=/opt/python3.5 --enable-shared
make && make install
ln -s /opt/python3.5/bin/python3 /usr/bin/python3
echo "/opt/python3.5/lib" > /etc/ld.so.conf.d/python3.5.conf
ldconfig

检测python3.5是否安装成功

python3 --version

3. 升级pip

因为python3.5自带pip,setuptools

/opt/python3.5/bin/pip3 install --upgrade pip
ln -s /opt/python3.5/bin/pip /usr/bin/pip

4. 升级setuptools

wget https://bootstrap.pypa.io/ez_setup.py -O - | python3
ln -s /opt/python3.5/bin/easy_install /usr/bin/easy_install

安装脚本(用2.7)

#!/usr/bin/python
order_list=[yum -y groupinstall "Development tools",             yum -y install openssl-devel sqlite-devel bzip2-devel ncurses-devel gdbm-devel readline-devel tcl-devel             tk-devel xz-devel zlib-devel db4-devel libpcap-devel wget,            cd /usr/local/src,            wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz,            tar -zxf /usr/local/src/Python-3.5.1.tgz,cd /usr/local/src/Python-3.5.1,./configure --prefix=/usr/local --enable-shared,            make && make install,            ln -s /opt/python3.5/bin/python3 /usr/bin/python3,            echo "/opt/python3.5/lib" > /etc/ld.so.conf.d/python3.5.conf,ldconfig,            /opt/python3.5/bin/pip3 install --upgrade pip,            ln -s /opt/python3.5/bin/pip /usr/bin/pip,            cd /usr/local/src,            wget https://bootstrap.pypa.io/ez_setup.py -O - | python3,            ln -s /opt/python3.5/bin/easy_install /usr/bin/easy_install]
import os,sys
def run_command(order):
    for i in order:
        dir_list = i.split()
        if dir_list[0] == cd:
            os.chdir(dir_list[1])
            print(os.getcwd())
            continue
        else:
            try:
                result_status = os.system(i)
            except Exception as e:
                sys.exit(1)
run_command(order_list)

 

Centos7安装Python3.5

标签:sqli   centos7安装   下载   /usr   readline   print   nbsp   class   enable   

原文地址:http://www.cnblogs.com/chimeiwangliang/p/7748580.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!