今天照着别个的方法安装了下scrapy,把主要步骤记录在这里,方便日后再次安装!
1.首先保证已经安装python2.X,我安装的是2.7
2.easy_install工具安装:下载:http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe 双击执行。那么执行后在python根目录下的scripts文件夹里就会有easy_install.py等文件了,都带有easy_install字眼。easy_install工具安装完成。
3.zope_interface的安装:http://pypi.python.org/pypi/zope.interface#download , 选择符合当前环境的可供下载的egg,如:zope.interface-4.0.0-py2.7-win32.egg;把这个egg文件拷贝进入刚才我们说道的python根目录下的scripts目录,同easy_installs等文件一个目录位置;
进入cmd模式,在cmd模式下进入这个script目录,执行easy_install.py egg文件名,执行安装这个egg文件。
C:\Python27\Scripts>easy_install.exe zope.interface-4.0.0-py2.7-win32.egg
Processing zope.interface-4.0.0-py2.7-win32.egg
removing 'c:\python27\lib\site-packages\zope.interface-4.0.0-py2.7-win32.egg' (a
nd everything under it)
creating c:\python27\lib\site-packages\zope.interface-4.0.0-py2.7-win32.egg
Extracting zope.interface-4.0.0-py2.7-win32.egg to c:\python27\lib\site-packages
zope.interface 4.0.0 is already the active version in easy-install.pth
Installed c:\python27\lib\site-packages\zope.interface-4.0.0-py2.7-win32.egg
Processing dependencies for zope.interface==4.0.0
Finished processing dependencies for zope.interface==4.0.0
C:\Python27\Scripts>
C:\Python27\Scripts>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope.interface
>>> 无报错, 表示可以导入模块;
4.安装PyOpenSSL:在http://pypi.python.org/pypi/pyOpenSSL ;下载得到的egg文件pyOpenSSL-0.13-py2.7-win32.egg,按刚才安装zope.interface的方法,在安装pyOpenSSL,先将下载到的pyOpenSSL,拷贝到scripts文件夹中,然后进入到cmd模式下,在cmd模式中进入到对应的scripts文件夹下,执行easy_install.exe pyOpenSSL-0.13-py2.7-win32.egg,进行安装;
C:\Python27\Scripts>easy_install.exe pyOpenSSL-0.13-py2.7-win32.egg
Processing pyOpenSSL-0.13-py2.7-win32.egg
removing 'c:\python27\lib\site-packages\pyOpenSSL-0.13-py2.7-win32.egg' (and eve
rything under it)
creating c:\python27\lib\site-packages\pyOpenSSL-0.13-py2.7-win32.egg
Extracting pyOpenSSL-0.13-py2.7-win32.egg to c:\python27\lib\site-packages
pyOpenSSL 0.13 is already the active version in easy-install.pth
Installed c:\python27\lib\site-packages\pyopenssl-0.13-py2.7-win32.egg
Processing dependencies for pyOpenSSL==0.13
Finished processing dependencies for pyOpenSSL==0.13
>>> import OpenSSL
>>>
无报错, 表示可以导入模块;
5.安装twisted.twisted的下载链接:
http://twistedmatrix.com/trac/wiki/Downloads 下载 Twisted-12.1.0.win32-py2.7.exe
6.安装lxml的选项,进入:http://users.skynet.be/sbi/libxml-python/ 下载libxml2-python-2.7.7.win32-py2.7.exe
7..安装scrapy。进入scrapy 官网:http://scrapy.org/download/ 这个链接,点击Scrapy 0.12 on PyPI ;下载得到文件 Scrapy-0.14.4.tar.gz
http://doc.scrapy.org/en/0.14/intro/install.html#windows
由于我的是win系统,所以按照官方方法,没必要下载此包,直接用下面方法在命令行中安装即可:
Installing with easy_install
You can install Scrapy using setuptools‘s easy_install
easy_install -U Scrapy
Installing with pip¶
You can install Scrapy using pip with:
pip install Scrapy
这个时候查看是否在python目录下的第三方目录中(即site-package)中是否有关于scrapy的文件夹了,然后在cmd模式中
任意目录输入scrapy,提示出错误,则需要把python根目录下的script目录设置到环境变量中。将 C:\Python27\Scripts加到path中;
重新打开一个cmd窗口,在任意位置执行scrapy命令,得到下列页面,表示环境配置成功.
C:\Python27\Scripts>cd ..
C:\Python27>scrapy
Scrapy 0.14.4 - no active project
Usage:
scrapy <command> [options] [args]
Available 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
Use "scrapy <command> -h" to see more info about a command
C:\Python27>
以上说明安装成功;
至此,如果一切顺利的话,就算安装成功了,
在cmd窗口中,选择一个路径D:\workspace,在这里新建一个主机的项目:scrapy startproject mobile 表示创建一个项目,根目录名为mobile
如果没有报出错信息,那么表示项目新建成功。通过文件管理,可以明确的看到这样的一个文件
系统已经生成,并且在对应的文件夹下又对应的文件。