python - 我在 google colab 中将图像转换为文本时出现 TesseractError : (2, 'Usage: pytesseract [-l lang] input_file' ) 错误

标签 python machine-learning computer-vision ocr

下面是我的代码

im=Image.open("/root/ppm_to_jpg/6e196d3b-adec-45ab-b036-5833f96f1bc0-2.jpg")
pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/pytesseract'
text=pytesseract.image_to_string(im,lang="eng")
print (text)

我得到的错误是 TesseractError: (2, 'Usage: pytesseract [-l lang] input_file') 即使我已经设置了 pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/pytesseract

谁能建议我该怎么做

最佳答案

!sudo apt install tesseract-ocr

上面安装了 pytesseract 所需的依赖项。这非常重要,尤其是 !没有它,您将无法直接安装到底层操作系统。

!pip install pytesseract

这将安装 Python 绑定(bind)。

希望这对您有所帮助。

关于python - 我在 google colab 中将图像转换为文本时出现 TesseractError : (2, 'Usage: pytesseract [-l lang] input_file' ) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60718205/

相关文章:

python - 图像的水平翻转[python]

python - 训练自定义 NER 模型

clojure - 有人知道 Clojure 机器学习框架吗?

python - 为什么使用 SVM 线性内核的工作代码不能使用 RBF

python - 值错误: Could not find a format to write the specified file in single-image mode

python - 在散点图中创建 for 循环的问题

Python OpenSSL 生成公钥和私钥对

python - 更有效地拆分列

machine-learning - 在 tensorflow 中使用 get_variable 进行偏差的零初始化

machine-learning - 在这个暹罗实现中,如何获得最后一层的输出(A 和 B 张量的值)?