Aptfile:安装特定版本的 Tesseract-OCR

Aptfile: install a specific version of Tesseract-OCR

我在 Heroku 上部署了一个使用 Pytesseract 的应用程序。要在服务器上使用 Tesseract,我必须通过 Aptfile

安装 Tesseract

Aptfile

tesseract-ocr

在查看 Heroku Bash 后,我看到安装的 Tesseract 版本是 4.0.0。这个版本有一些影响我的应用程序的小错误(它不能像新版本那样很好地过滤字符)。如何在服务器上安装特定版本的 Tesseract-OCR?

How can I install a specific version of Tesseract-OCR on the server?

将版本放在包名后面。

来自 the Ubuntu Manpage for apt-get:

A specific version of a package can be selected for installation by following the package name with an equals and the version of the package to select

来自heroku-buildpack-apt README

To find out what packages are available, see: https://packages.ubuntu.com

如果您使用 Heroku-20 堆栈(当前默认堆栈),您应该搜索 Ubuntu 20.04 的包,因为它是基础技术。来自 the Heroku Stacks article:

Stack Version Base Technology Available since Supported through Status
Heroku-20 Ubuntu 20.04 2020 April 2025 Default

Ubuntu packages for tesseract-ocr for 20.04中当前的包版本是4.1.1-2build2:

Package: tesseract-ocr (4.1.1-2build2) [universe]

在这种情况下,Aptfile 行可能是:

tesseract-ocr=4.1.1-2build2

这就是安装特定版本的方式。

在你的情况下,我猜你正在使用 Heroku-18,因为 4.00~git2288-10f4998a-2tesseract-ocr 的版本 Ubuntu 18.04 根据 Ubuntu packages 并尝试安装更高版本可能会失败,因为它不可用。如果是这样的话,我建议使用 Heroku-20,默认情况下它应该使用该软件包的更新版本。