1. 運(yùn)行docker容器:
docker run -i –t centos /bin/bash#這時(shí)進(jìn)入centos虛擬環(huán)境
# 安裝依賴
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
#刪除舊版本的依賴,并創(chuàng)建軟鏈接
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.5 /usr/bin/python
#沒想到最后python3與python2沖突了宝泵,導(dǎo)致yum不能用了,不過修改一下
vi /usr/bin/yum
vi /usr/libexec/urlgrabber-ext-down? #這兩個(gè)文件第一行的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..執(zhí)行成功之后固惯,再次執(zhí)行yum install python-pip
3.對安裝好的pip進(jìn)行升級 pip install –upgrade pip