安装tesseract5
1.安装依赖包
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:alex-p/tesseract-ocr-devel
sudo apt-get update
2.安装 Tesseract 5.x
sudo apt-get install -y tesseract-ocr tesseract-ocr-eng
如果需要其他语言数据包,可以运行: 将 xxx 替换为相应的语言代码,如 chi-sim 为简体中文。
sudo apt-get install tesseract-ocr-xxx
安装 Leptonica
sudo apt-get install libleptonica-dev
验证安装:
tesseract --version
设置环境变量(可选)
如果需要在 Python 脚本中使用 Tesseract,可能还需要设置环境变量。编辑 ~/.bashrc 文件,添加以下行:
export TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata
保存后,运行 source ~/.bashrc 使环境变量生效。
通过这些步骤,您就可以在 Ubuntu 系统上成功安装 Tesseract 5.x 版本和 Leptonica 库了。