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
网友评论