* 安装python3以及docker
yum install docker
docker pull centos
service docker start
systemctl enable docker //设置为开机自启动
docker images
#开始安装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即可
* 安装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
按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即可