CentOS 7安装TrWebOCR
Centos 7 安装TrWebOcr
环境说明
虚拟机环境:centos 7 全新环境,做了少量优化,比如关闭防火墙,yum源使用阿里云等
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
# 更改yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装系统时选择Minimal Install,组件选择"Debugging Tools","Compatibility Libraries","Development Tools"。如果安装系统时没有选择组件,也可以用yum groupinstall 来安装
yum groupinstall "Debugging Tools" "Development Tools" "Compatibility Libraries"
编译安装python3
1,安装依赖包
yum install zlib-devel openssl-devel libSM libXrender libXext libffi-devel -y
尽量都安装上,不然后面会报错
2,下载python 包
#https://www.python.org/downloads/source/
#这个网址有各个版本的python,选择自己需要的版本
mkdir ~/tools
cd ~/tools
wget https://www.python.org/ftp/python/3.7.13/Python-3.7.13.tgz
#我存放的位置在/root/tools 中
3,解压并安装
mkdir /usr/local/python3.7
cd ~/tools
tar -zxvf Python-3.7.13.tgz
cd Python-3.7.13
./configure --prefix=/usr/local/python3.7
make && make install
4,创建软链接
ln -s /usr/local/python3.7/bin/python3 /usr/bin/python3
ln -s /usr/local/python3.7/bin/pip3 /usr/bin/pip3
5,更改pip源
mkdir ~/.pip
touch ~/.pip/pip.conf
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
EOF
cat ~/.pip/pip.conf
其他国内源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
安装TrWebOcr
1,下载TrWebOcr
mkdir /apps
cd /apps
git clone https://gitee.com/alisen39/TrWebOCR.git
2,安装依赖
cd /apps/TrWebOCR
pip3 install -r requirements.txt
这时候执行 python3 backend/main.py
会报下面的错误
OSError: /lib64/libstdc++.so.6: version 'GLIBCXX_3.4.20' not found (required by /apps/TrWebOCR/backend/tr/libtr.so)
解决方法(参考: https://www.jianshu.com/p/050b2b777b9d ):
cd ~/tools
wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip
unzip libstdc.so_.6.0.26.zip
cp libstdc++.so.6.0.26 /usr/lib64
cd /usr/lib64
# 删除/usr/lib64原来的软连接libstdc++.so.6
rm -f libstdc++.so.6
# 链接新的版本
ln -s libstdc++.so.6.0.26 libstdc++.so.6
3,运行TrWebOCR
cd /apps/TrWebOCR/
python3 backend/main.py
#正常运行
4,最后,可以安装tmux,让TrWebOCR运行到tmux。
# 安装tmux
yum install tmux -y
# 创建新传话, tr1是自定义会话名称
tmux new -s tr1
# 退出会话,让会话在后台运行
# 在会话中按 ctrl+b d 退出会话
# 列出已创建会话
tmux ls
# 在会话中按 ctrl+b s查看会话
# 重新进入会话
tmux a -t tr1
# 关闭会话
tmux kill-session -t tr1
# 在会话中按 ctrl+d 关闭当前会话
# 重命名会话
tmux rename-session -t tr1 tr2