zoukankan      html  css  js  c++  java
  • CentOS 6 安装 python 2.7 和 mod_wsgi 运行pyocr[tesseract]

      最新版本的tesseract-ocr 3.0.4 需要运行于python2.7版本以上,因此需要升级系统中默认的2.6版本python及Mod_WSGI

    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

  • 相关阅读:
    戴尔服务器IDRAC命令配置IP地址
    python 生成excel,并下载到本地
    python api
    python发送邮件
    大型线上系统迁移为分布式系统案例
    2014程序员之路
    Java EnumSet工作原理初窥
    C# 引用访问权限
    分享一些我的入门经历
    分享一些我的阅读习惯
  • 原文地址:https://www.cnblogs.com/dajianshi/p/4953054.html
Copyright © 2011-2022 走看看