美文网首页
在docker创建的centos容器里,配置python3环境

在docker创建的centos容器里,配置python3环境

作者: 长歌行夜一 | 来源:发表于2020-05-13 00:43 被阅读0次

    1. 运行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 wgetwget 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/localcd/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即可

    * 安装pip3

    1:安装依赖yum install openssl-devel  -y

    yum install zlib-devel  -yyum 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   

    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

    方法1:

    wget --no-check-certificatehttps://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz

    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

    方法2:

    1.yum -y install epel-release

    2..执行成功之后,再次执行yum install python-pip

    3.对安装好的pip进行升级 pip install –upgrade pip

    相关文章

      网友评论

          本文标题:在docker创建的centos容器里,配置python3环境

          本文链接:https://www.haomeiwen.com/subject/tjjkqhtx.html