python-inotify 在linux上安装
原创
©著作权归作者所有:来自51CTO博客作者mapaware的原创作品,请联系作者获取转载授权,否则将追究法律责任
python-inotify 在linux上安装
0 下载
$ wget --no-check-certificate https://pypi.python.org/packages/source/p/pathlib/pathlib-1.0.1.tar.gz
$ wget --no-check-certificate https://bitbucket.org/JanKanis/python-inotify/get/2193c8bdeb3b.zip
1 Ubuntu14.04
python2.7.6
gcc4.8.2
1.1 pathlib
$ cd pathlib-1.0.1
$ sudo python setup.py install
1.2 python-inotify
$ cd JanKanis-python-inotify-2193c8bdeb3b
$ sudo python setup.py install
1.3 测试
$ cd JanKanis-python-inotify-2193c8bdeb3b/examples
$ python simple.py
2 RHEL6.4
python2.7.9.
gcc-4.4.7
2.1 pathlib
# cd pathlib-1.0.1
# python setup.py install
2.2 python-inotify
# cd JanKanis-python-inotify-2193c8bdeb3b
# python setup.py install
出现IN_EXCL_UNLINK错误, 在JanKanis-python-inotify-2193c8bdeb3b/inotify/_inotify.c的开头添加下面的代码:
/* _inotify.c */
...
/* Exclude events on unlinked objects. */
#ifndef IN_EXCL_UNLINK
# define IN_EXCL_UNLINK 0x04000000
#endif
3 RHEL5.4
python2.5
gcc-4.1.x
3.1 首先升级python
1) 从源码安装依赖zlib-devel:
## get zlib-devel source and build install it
$ wget --no-check-certificate http://zlib.net/zlib-1.2.8.tar.gz
$ tar -zxf zlib-1.2.8.tar.gz
$ cd zlib-1.2.8
$ ./configure
$ make && make install
#### /usr/local/include/zlib.h zconf.h
2) 从源码安装依赖python-devel:
$ wget --no-check-certificate https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
$ tar -zxf Python-2.7.9.tgz
$ cd Python-2.7.9
$ ./configure -–with-zlib=/usr/local/include --enable-unicode=ucs4
$ make && make install
## test:
$ python
>>> import zlib
--enable-unicode=ucs4太重要了, 如果不指定这个, 安装python-inotify后运行测试程序simple.py时会出现错误:
ERROR: undefined symbol: PyUnicodeUCS4_FromFormat
3.2 安装python-inotify
参考2.1, 2,2.