1、修改yum源(这样以后下载依赖包就不受redhat限制了):
1.1、删除redhat7.0系统自带的yum软件包;
rpm -qa| grep yum | xargsrpm -e--nodeps
1.2、自行下载所需要的软件包;
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-42.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-42.el7.noarch.rpm
1.3、根据依赖项安装;
输入指令rpm -ivh yum-*
,遇到报错,依赖项问题。
另外再回去找安装包下载下来:
Wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-25.el7.x86_64.rpm
1.4、输入指令更新rpm
rpm -Uvh rpm-4.11.3-25.el7.x86_64.rpm –nodeps
再次运行rpm -ivh yum-*
,可以正常安装了。
1.5、新建repo配置文件。
vim /etc/yum.repos.d/CentOS-Base.repo
输入以下内容:
#CentOS-Base.repo
#
# The mirror system uses the connectingIP address of the client and the
# update status of each mirror to pickmirrors that are updated to and
# geographically close to theclient. You should use this for CentOSupdates
# unless you are manually picking othermirrors.
#
# If the mirrorlist= does not work foryou, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extendfunctionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
2、 首先安装两个必要的依赖项,否则后续的pip安装会失败
安装必要依赖项
yum install openssl-devel -y
yum install zlib-devel –y
3、下载相应的Pytho3.xxn版本,地址:https://www.python.org/downloads/release/python-362/
(我用的是3.6.2)
4、解压并安装
解压:tar -xf Python-3.6.2.tar.xz
5、进入python-3.6.2目录
6、执行:./configure --prefix=“path” (–prefix=“path”可以不用,就使用默认目录/usr/local/bin/就好),如果提示:noacceptable C compiler found in $PATH,说明没有提示没有GCC编译器环境,执行:yum -y install gcc,如果运行失败,说明你的yum源没有修改成功,重复执行上面步骤。
7、执行make
8、执行make install 安装完成
9、升级pip3到9.0.3: pip3 install --upgrade pip
10、安装Twisted(scrapy依赖Twisted)
wget https://twistedmatrix.com/Releases/Twisted/17.1/Twisted-17.1.0.tar.bz2
tar -jxvf Twisted-17.1.0.tar.bz2
cd Twisted-17.1.0
python3 setup.py install
cd ..
11、 安装scrapy
pip3 install scrapy
12、 导入Python3所需三方库
Pip3 install –r requirments.txt
导入完成