在安裝scrapy的前提需要安裝python,pip,setuptools,OpenSSL,lxml
安裝python3.5,pip參考這篇文章
安裝lxml:
安裝之前記得安裝libxslt和libxml
yum install libxml* -y
yum install libxslt* -y
wget http://lxml.de/files/lxml-3.1.2.tgz
tar xzvf lxml-3.1.2.tgz
cd lxml-3.1.2
python setup.py build
python setup.py install
#驗證是否安裝成功
shell > python
>>> import lxml
|
爲了確保依賴被安裝,執行命令:sudo yum install gcc libffi-devel python-devel openssl-devel
單獨裝Twisted:
tar -jxvf Twisted-15.2.1.tar.bz2
cd Twisted-15.2.1python setup.py install
檢驗:
>>>import Twisted
此時twisted已經安裝成功。
在驗證import OpenSSL時出現錯誤:ImportError: No module named 'cryptography'
然後單獨安裝easy_install cryptography,出現:from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
重裝一下setuptools即可解決:wget https://bootstrap.pypa.io/ez_setup.py -O - | python
重新執行easy_install cryptography,安裝成功。
驗證:
>>>import OpenSSL
重新裝scrapy:easy_install scrapy
出現錯誤:ImportError: Twisted requires Python 2.7 or later.
網上說需要首先安裝Twsisted的兩個依賴庫pyOpenSSL和pycrypto 。
easy_install pyOpenSSL
easy_install pycrypto
執行easy_install scrapy
驗證:>>>import scrapy
則安裝成功!