CentOS 6 安装 python 2.7 和 mod_wsgi 运行pyocr[tesseract]
2015-11-10 14:51
609 查看
最新版本的tesseract-ocr 3.0.4 需要运行于python2.7版本以上,因此需要升级系统中默认的2.6版本python及Mod_WSGI
1,下载安装Python-2.7.10
2,安装python2.7的mod_wsgi
如果安装python2.7.10时没有加入--enable-shared参数,安装mod_wsgi时就会报如下错误:"recompile with -fPIC"
3, 替换系统默认Mod_wsgi
4,运行apache,报错找不到ocr模块,然而在调试环境下没有问题,经查看pyocr的源码发现,pyocr.get_available_tools() 是通过在环境变量os.environ["PATH"]中查看有没有tesseract命令,因此需要将tesseract的安装路径/usr/local/bin/tesseract加入PATH中,然后重新启动,或者在python程序中自己加入路径/usr/local/bin
1,下载安装Python-2.7.10
>tar xJvf Python-2.7.10.tar6.xz >cd Python-2.7.10 # 这里,必须用–enable-shared,生成动态库,否则会遇到wsgi不能编译的问题。 >./configure --enable-shared >make && make install #替换原来的默认python >mv /usr/bin/python /usr/bin/python2.6 >ln -s /usr/local/bin/python2.7 /usr/bin/python #设置lib路径 >ldconfig /usr/local/lib #查看python状态 >python -V
2,安装python2.7的mod_wsgi
>pip install mod_wsgi
如果安装python2.7.10时没有加入--enable-shared参数,安装mod_wsgi时就会报如下错误:"recompile with -fPIC"
...... /usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython2.7.a: could not read symbols: Bad value collect2: ld returned 1 exit status apxs:Error: Command failed with rc=65536
3, 替换系统默认Mod_wsgi
>mv /usr/lib64/httpd/modules/mod_wsgi.so /usr/lib64/httpd/modules/mod_wsgi.so.origin >ln -s /usr/local/lib/python2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so /usr/lib64/httpd/modules/mod_wsgi.so
4,运行apache,报错找不到ocr模块,然而在调试环境下没有问题,经查看pyocr的源码发现,pyocr.get_available_tools() 是通过在环境变量os.environ["PATH"]中查看有没有tesseract命令,因此需要将tesseract的安装路径/usr/local/bin/tesseract加入PATH中,然后重新启动,或者在python程序中自己加入路径/usr/local/bin
相关文章推荐
- CentOS7 mono环境连接WCF
- linux下解压命令大全
- linux下文件夹的创建、复制、剪切、重命名、清空和删除命令
- Linux 安装 windows 字体
- Centos5.8 x86_64下安装DRBD+Heartbeat+NFS
- Linux下实现USB口的热插拔事件触发
- linux时区问题
- 辛星浅析linux下安装rails对于sqlite3缺少的问题
- [Linux] awk命令笔记 入门
- linux server 向外网发送邮件
- Linux下搭建php+apach+mysql+svn
- Linux Hellpworld 驱动程序加载
- linux查看本机IP、gateway、dns
- Linux下*.tar.gz文件解压缩命令
- php Linux安装
- Linux vi 操作命令整理
- Linux学习方法分享
- Linux--FFMPEG2.8 安装
- Linux进程间通信(IPC)编程实践(三) 详解System V消息队列(1)
- linux文件系统文件路径,inode,block号,sector号的相互转换