• 为CentOS下的Docker安装配置python3【转】


    * 安装python3以及docker

    yum install docker
    docker pull centos
    service docker start
    systemctl enable docker    //设置为开机自启动
    docker images
    
     
    图片.png
    #开始安装docker
    docker run -i –t centos /bin/bash
    #这时进入centos虚拟环境
    yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel  -y
    yum -y install gcc automake autoconf libtool make
    #安装make编译所需的gcc,g++编译器
    
    #开始安装python3
    yum install wget
    wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
    tar zxvf Python-3.5.3.tgz
    mv Python-3.5.3 /usr/local
    cd /usr/local/Python-3.5.3 
    ./configure   
    make
    make install
    
    #删除旧版本的依赖,并创建软链接
    rm -rf /usr/bin/python
    ln -s /usr/local/bin/python3.5 /usr/bin/python
    
    #没想到最后python3与python2冲突了,导致yum不能用了,不过修改一下
    vi /usr/bin/yum
    vi /usr/libexec/urlgrabber-ext-down
    这两个文件开头的python为python2.7即可
    
     
    图片.png

    * 安装pip3

    1:安装依赖
    yum install openssl-devel   -y
    
    yum install zlib-devel  -y
    
    yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel -y
    
    2:安装setuptools
    wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
    tar -zxvf setuptools-19.6.tar.gz
    rm -rf setuptools-19.6.tar.gz
    cd setuptools-19.6
    python3 setup.py build
    python3 setup.py install
    
    
    3:安装pip
    wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
    tar -zxvf pip-8.0.2.tar.gz
    rm -rf pip-8.0.2.tar.gz
    cd pip-8.0.2
    python3 setup.py build
    python3 setup.py install
    
    #更新为最新版
    pip install --upgrade pip  
    
    
     
    图片.png

    按ctral+d退出

    #下面是我想安装的库,可以忽略......
    pip3 install bs4 
    pip3 install requests 
    pip3 install socketserver 
    pip3 install selenium 
    pip3 install socket 
    pip3 install fake_useragentvi /usr/libexec/urlgrabber-ext-down
    
    没想到最后python3与python2冲突了,不过修改一下
    vi /usr/bin/yum
    vi /usr/libexec/urlgrabber-ext-down
    这两个文件开头的python为python2.7即可
    
  • 相关阅读:
    [TCP IP详解:学习笔记]UDP:用户数据协议
    [TCP IP详解:学习笔记]IP选路
    [TCP IP详解:学习笔记]IP:网络协议
    [TCP IP详解:学习笔记]TCP连接的建立与终止
    [TCP IP详解:学习笔记]ICMP:Internet控制报文协议
    [TCP/IP详解:学习笔记]链路层
    [TCP/IP详解:学习笔记]ARP:地址解析协议
    [TCP IP详解:学习笔记]TCP:传输控制协议
    [TCP IP详解:学习笔记]广播和多播
    [TCP IP详解:学习笔记]IGMP:Internet组管理协议
  • 原文地址:https://www.cnblogs.com/loveapple/p/9937030.html
Copyright © 2020-2023  润新知