所以我是一个编程初学者。我正试图将jpeg文件转换为文本文件,但无法这样做。我得到一个错误
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
print(pytesseract.image_to_string(Image.open('A_1.jpg')))
我浏览了文档,找到了错误出现的原因和解决方案:
'If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
# Example tesseract_cmd = r'C:Program Files (x86)Tesseract-OCRtesseract'
所以根据文档,我应该包括安装的可执行文件的完整路径,但我不知道如何获得路径,。我在Linux上工作,是Linux的新手。你能帮我吗?
安装后如何获得python包的完整路径?
要找到python包的路径,可以这样做
import pytesseract
print(pytesseract.__file__)
打印类似
的内容WPy64-3880python-3.8.8.amd64libsite-packagespytesseract__init__.py