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
网友评论