0. 安装顺序很重要
我们需要在linux中安装zlib-devel包,进行支持。
我们需要在linux中安装openssl包,进行支持。
yum install python-devel
yum install openssl-devel
yum install zlib-devel
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
1. 安装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
cd setuptools-19.6
python setup.py build
python setup.py install
2. 安装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
cd pip-8.0.2
python setup.py build
python setup.py install
pip install --upgrade pip
3. 安装python3
cd /root/
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
tar -zxvf Python-3.6.0.tgz
cd Python-3.6.0
./configure
make
make install
修改系统默认的Python路径,因为在终端中输入Python命令时默认是指向Python2.6.6
mv /usr/bin/python /usr/bin/python-2
建立新的软连接,指向Python-3.6.0:
注:这里的python36是第4步指定的安装路径,python3.6是Python包里的可执行程序
ln -s /root/Python-3.6.0/python /usr/bin/python
ln -s /home/yy/Python-3.6.0/python /usr/bin/python
mv /usr/bin/python /usr/bin/python2bak
ln -s /usr/bin/python3 /usr/bin/python
4. 安装scrapy
pip install scrapy
pip install PyMySQL
pip install lxml
pip install bs4
pip install cryptography --force-reinstall
pip install UserAgent
pip install fake-useragent
pip install pywin32 针对windows的
pip install bloomfilter4py3
5.更改yum配置,因为其要用到python2才能执行,否则会导致yum不能正常使用
vi /usr/bin/yum
把#! /usr/bin/python修改为#! /usr/bin/python2
vi /usr/libexec/urlgrabber-ext-down
把#! /usr/bin/python 修改为#! /usr/bin/python2