sách gpt4 ai đã đi

python-2.7 - 为什么 pytesseract 导致 AttributeError : 'NoneType' object has no attribute 'bands' ?

In lại 作者:行者123 更新时间:2023-12-01 10:37:29 31 4
mua khóa gpt4 Nike

我正在尝试开始使用 pytesseract,但正如您在下面看到的,我遇到了问题。

我发现人们得到的似乎是相同的错误,他们说这是 PIL 1.1.7 中的错误。也有人说是PIL懒惰导致的,需要强制PIL在打开后用im.load()加载图片,但似乎并没有什么用。非常感谢收到任何建议。

K:\Glamdring\Projects\Images\OCR>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> import pytesseract
>>> pytesseract.image_to_string(Image.open('foo.png'))
Theo dõi (cuộc gọi gần đây nhất là cuộc gọi cuối cùng):
Tệp "", dòng 1, trong
File "build\bdist.win32\egg\pytesseract\pytesseract.py", line 143, in image_to_string
File "c:\Python27_32\lib\site-packages\PIL\Image.py", line 1497, in split
if self.im.bands == 1:
AttributeError: 'NoneType' object has no attribute 'bands'

1 Câu trả lời

尝试分别使用 Image 和 pytesseract 模块中的对象。
它解决了我的问题:

thử:
import Image
ngoại trừ ImportError:
from PIL import Image
import pytesseract

img = Image.open('myImage.jpg')
img.load()
i = pytesseract.image_to_string(img)
in tôi

关于python-2.7 - 为什么 pytesseract 导致 AttributeError : 'NoneType' object has no attribute 'bands' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32791563/

31 4 0
Bài viết được đề xuất: build - 突然 grunt 构建失败
Bài viết được đề xuất: java - 如何在 Java Mad Libs 程序中使用随机发生器?
Bài viết được đề xuất: JavaFX init() 方法将字段重置为 null
Bài viết được đề xuất: 找不到 javafx.controls JavaFX 11/JDK 11.0.1
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com