• 欢迎访问金笔头博客,这是一个持续学习者的自留地,欢迎访问我的github:点击进入

Centos 6.5 安装 Scrapy

Centos eason 2997次浏览 2个评论 扫描二维码

1.查看Python版本

[root@WYS ~]# python -V
Python 2.6.6
[root@WYS ~]#

2.更新系统软件包,时间有点长

[root@WYS ~]# yum -y update

3.安装GCC软件套件,不然下面安装Python2.7的时候执行./configure的时候会报错

[root@WYS ~]# yum install gcc

4.安装后续步骤所需模块,否则下面安装pip会报错

[root@WYS ~]# yum install -y python-devel libffi-devel zlib zlib-dev openssl-devel sqlite-devel bzip2-devel

5. 安装setuptools,这个工具在安装python模块的时候非常方便

[root@WYS~]#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
[root@WYS ~]# tar zxvf setuptools-0.6c11.tar.gz
[root@WYS ~]# cd setuptools-0.6c11 && python setup.py install

6.升级Python到2.7版本

[root@WYS ~]# wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
[root@WYS ~]# tar -xvf Python-2.7.6.tar.xz && cd Python-2.7.6
[root@WYS Python-2.7.6]# ./configure
[root@WYS Python-2.7.6]# make && make altinstall

7.更改系统默认使用的为Python2.7但因为yum不兼容Python2.7所以修改yum使其仍然使用Python2.6运行

[root@WYS Python-2.7.6]# whereis python
python:/usr/bin/python /usr/bin/python2.6 /usr/lib/python2.6 /usr/local/bin/python2.7 /usr/local/bin/python2.7-config
/usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
[root@WYS Python-2.7.6]# mv /usr/bin/python /usr/bin/python.bak
[root@WYS Python-2.7.6]# ln -s /usr/local/bin/python2.7 /usr/bin/python
[root@WYS Python-2.7.6]# which yum
/usr/bin/yum
[root@WYS Python-2.7.6]# vi /usr/bin/yum
将#!/usr/bin/python改为
#!/usr/bin/python2.6

8.验证Python默认版本

[root@WYS ~]# python -V
Python 2.7.6
[root@WYS ~]#

9.安装pip

[root@WYSPython-2.7.6]#wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz --no-check-certificate
[root@WYS Python-2.7.6]# tar -zxvf distribute-0.6.49.tar.gz
[root@WYS Python-2.7.6]# cd distribute-0.6.49
[root@WYS distribute-0.6.49]# python setup.py install
[root@WYS distribute-0.6.49]# which easy_install
/usr/local/bin/easy_install
[root@WYS distribute-0.6.49]# /usr/local/bin/easy_install pip

10. 安装Twisted

[root@WYS distribute-0.6.49]# easy_install Twisted

11.安装zope.interface

[root@WYSdistribute-0.6.49]#wget http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.3.tar.gz
[root@WYS distribute-0.6.49]# tar zxvf zope.interface-3.6.3.tar.gz
[root@WYS distribute-0.6.49]# cd zope.interface-3.6.3 && python setup.py install

12.安装libxml2

[root@WYS zope.interface-3.6.3]# yum install libxml2 -y
easy_install libxml2

13.安装pyopenssl

[root@WYS zope.interface-3.6.3]# yum install pyOpenSSL

14.安装w3lib

[root@WYS zope.interface-3.6.3]# easy_install -U w3lib

15.安装libxslt-devel、libxml2-devel

[root@WYS zope.interface-3.6.3]yum install libxslt-devel
[root@WYS zope.interface-3.6.3]python setup.py install
[root@WYS zope.interface-3.6.3]# yum install libxml2-devel

15.安装scrapy

[root@WYS zope.interface-3.6.3]# pip install Scrapy

16.验证scrapy,如果没有报错说明安装成功

[root@WYS ~]# scrapy
Scrapy 1.0.3 - no active project
Usage:
   scrapy <command> [options] [args]
   Available commands:
   bench Run quick benchmark test
   commands
   fetch Fetch a URL using the Scrapy downloader
   runspider Run a self-contained spider (without creating a project)
   settings Get settings values
   shell Interactive scraping console
   startproject Create new project
   version Print Scrapy version
   view Open URL in browser, as seen by Scrapy
   [ more ] More commands available when run from project directory
   Use "scrapy <command> -h" to see more info about a command

金笔头博客, 版权所有丨如未注明 , 均为原创, 转载请注明Centos 6.5 安装 Scrapy
喜欢 (1)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(2)个小伙伴在吐槽
  1. qGYm0T Im grateful for the post.Thanks Again. Much obliged.
    crorkservice2016-02-04 08:41 Reply Windows XP | Internet Explorer 6.0
  2. I am so grateful for your article.Really thank you! Really Great.
    femaleagent2016-01-02 02:08 Reply Windows XP | Firefox 3.5.3