ICode9

精准搜索请尝试: 精确搜索
首页 > 互联网> 文章详细

linux centos7安装scrapy_Scrapy1.5中文文档_Scrapy 中文网

2018-09-30 15:02:07  阅读:633  来源: 互联网

标签:


scrapy中文教程主要介绍,centos7 linux下scrapy的安装,python版本是2.7!上面我们已经介绍了如何安装centos linux,如果还木有安装好centos,请移步:《scrapy centos7 linux安装(一):centos安装》 安装好之后,我们来看如何在centos7下面安装scrapy。这里有一点特殊的地方要说下,相对于Windows,centos7自带python2.7,也就是说我们并不需要再安装python了,当然如果你想使用python3.6,请看另一篇文章:《centos7 linux安装scrapy(三):python3.6安装scrapy1.4》

!接下来我们看如何在centos7 下python2.7安装scrapy!

先提一下,linux的一些命令,比如登录、cd、yum……这些前戏就不多说了,不清楚的大家不清楚的去百度一下,这里我直接进入正题了!在linux下面我们就用pip安装,我们先在linux命令行输入:

pip install scrapy

试一下,看能不能安装!结果:

[root@localhost ~]# pip install scrapy
-bash: pip: 未找到命令

可以看到,没有pip命令,那我们需要先安装pip:

yum -y install epel-release

输入以上命令,然后当出现下图时,说明安装完成(一半):

centos linux 安装scrapy

接着再输入一下命令:

yum install python-pip

里面我们需要输入[y/d/n],我们一路输入:y

centos linux 安装scrapy

当出现:完毕!字样,说明pip安装完成!接下来我们安装scrapy,用的命令就是我们狠熟悉的pip命令了,如下:

pip install scrapy

当我们满怀欢喜安装的时候,发现:

Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L1Q1wb/Twisted/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-QWsI2y-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-L1Q1wb/Twisted/

You are using pip version 8.1.2, however version 9.0.1 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

神马情况,好像是告诉我们需要使用:

pip install --upgrade pip

更新pip版本,那我们就试试!

centos linux安装scrapy

好了,更新完成了,再试试pip install scrapy看还会不会出错!果然,哈哈,又出错:

error: command 'gcc' failed with exit status 1

Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-S4duRv/Twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-tAiOQb-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-S4duRv/Twisted/

红色、错误、error一点都不可怕,可怕的是不敢把错误踩在脚下,我们继续解决错误,大家要学会看提示,也就是上面error后面的或是红色的提示,虽然是英文,但是都是一些常见的,慢慢多看就熟悉了,以后出现这样的错误还多,何不早早的试试?好,我们来看上面提示大致意思是:没有‘gcc’,那我们先来装gcc吧,centos安装gcc灰常简单,命令如下:

yum install gcc

如果出现让你选择:[y/d/n] 不要犹豫,一路的:y ,然后就是等待,直到出现:完毕!字样说明gcc安装完成,如图:

centos linux安装scrapy

安装完gcc后,我们再次输入:pip install scrapy试试,看能不能愉快的安装,呵呵,又有坑:

编译中断。

    error: command 'gcc' failed with exit status 1

    ----------------------------------------

Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-CRTnLK/Twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-geKgvU-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-CRTnLK/Twisted/

网上查了一下,原来是差这么几个模块:libffi-devel 、 python-devel 、openssl-devel,一起安装一下,命令行输入:

yum install gcc libffi-devel python-devel openssl-devel -y

安装完成之后,再次输入:pip install scrapy,你会发现奇迹就在眼前,scrapy成功安装,输入:scrapy,当出现如下输出,说明安装完成

centos linux安装scrapy

其实这就是一个填坑的过程,之所以出现这些问题,是我们使用centos mini(最小安装),导致许多包没有,所以需要我们手动安装一下这些包,其实用到的命令就这么几个:

yum -y install epel-release
yum install python-pip -y
pip install --upgrade pip
yum install gcc -y
yum install gcc libffi-devel python-devel openssl-devel -y
pip install scrapy
ok至此,centos7 linux下python2.7安装scrapy安装完毕!路途艰险,但愿你学到的是解决问题的思路!

标签:
来源: http://www.scrapyd.cn/doc/156.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有