安装pip
C:Python27\Lib\site-packageses\easy_install.py pip
用pip安装scrapy
pip install scrapy
报错:Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat)
下载Microsoft Visual C++ Compiler for Python 2.7
https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
再次使用pip安装
pip install scrapy
报错:******Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
set STATICBUILD=true && pip install lxml
再次使用pip安装
pip install scrapy
至此我的scrapy安装成功了
查看scrapy版本
scrapy version
scapy的安装需要python的版本为2.7,而centos6.5自带的python版本是2.6的,需要升级。升级方法请参考:http://www.05do.com/blog/content/196
yum -y install python27-pip python27-lxml python27-pillow python27-twisted python27-w3lib python27-zope pyOpenSSL27 MySQL-python27 ln -s /usr/bin/pip2.7 /usr/bin/pip
pip install scrapy
注:PUIAS源也存在scrapy,可以用yum安装,但是版本比较低,为 v0.20.2,而截至到当前时间,scrapy的版本已经更新到1.10了,所以这里选择用pip安装最新版本
scrapy version
输出:
Scrapy 1.1.0
最近在研究scrapy,需要用到python2.7,但是CentOS6.5的python版本是2.6,现在需要升级为2.7。
rpm -ivh https://centos6.iuscommunity.org/ius-release.rpm
yum -y install python27 python27-devel python27-pip python27-setuptools
mv /usr/bin/python /usr/bin/python26 cp /usr/bin/python2.7 /usr/bin/python mv /usr/bin/pip /usr/bin/pip26 cp /usr/bin/pip2.7 /usr/bin/pip
python --version
输出:
Python 2.7.13
vi /usr/bin/yum
修改#!/usr/bin/python为#!/usr/bin/python26
到此,python的版本升级工作已完成。
PhpStorm
https://www.jetbrains.com/phpstorm/download/other.html
PyCharm
https://www.jetbrains.com/pycharm/download/other.html
IntelliJ Idea
https://www.jetbrains.com/idea/download/other.html
CLion
https://www.jetbrains.com/clion/download/other.html
GoLand
https://www.jetbrains.com/go/download/other.html
WebStorm
https://www.jetbrains.com/webstorm/download/other.html
在Linux平台下我们可以利用2.6内核的inotify监控文件系统机制,通过rsync+inotify-tools+ssh实现触发式远程实时同步,即,当源目录下的文件或目录有变化时,会立即同步到目标目录。
yum install rsync inotify-tools
SRC=/data/webroot/admin.zhugexuetang/ DST=root@10.19.196.161:/data/webroot/admin.zhugexuetang/ inotifywait -mrq -e modify,delete,create,attrib ${SRC} | while read D E F do #rsync -az --delete --exclude='runtime' --exclude='.git' $SRC $DST rsync -az --exclude='runtime' --exclude='.git' $SRC $DST done
相关注解如下:
inotifywait -mrq -e modify,delete,create,attrib ${SRC} | while read D E F
-m 是保持一直监听
-r 是递归查看目录
-q 是打印出事件
-e create,move,delete,modify,attrib 是指 “监听 创建 移动 删除 写入 权限” 事件
rsync -azt --delete --exclude='runtime' --exclude='.git' $SRC $DST
-a 存档模式
-z 压缩文件数据在传输
-t 维护修改时间
-delete 删除于多余文件
要排除同步某个目录时,为rsync添加--exculde=PATTERN参数,注意,路径是相对路径,具体查看man rsync。
要排除某个目录的事件监听的处理时,为inotifywait添加--exclude参数,具体查看man inotifywait。
inotifywait 命令产生三个返回值,分别是“日期,时间,文件” 这3个返回值会做为参数传给read,因此脚本中的“while read D E F” 写法细化了返回值。