Error: pytesseract.pytesseract.TesseractNotFoundError:
ข้อผิดพลาด pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it'is not in your PATH หมายความว่า Python…
Error: pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’is not in your PATH
ข้อผิดพลาด pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it'is not in your PATH หมายความว่า Python ไม่สามารถหาตัวโปรแกรม Tesseract OCR ที่เป็นโปรแกรมภายนอกซึ่ง pytesseract ใช้ในการประมวลผลข้อความจากภาพ
วิธีแก้ไข
✅ 1. ติดตั้ง Tesseract OCR
Windows:
ดาวน์โหลด Tesseract จาก: https://github.com/tesseract-ocr/tesseract/wiki
ติดตั้ง แล้วจำไว้ว่า tesseract.exe อยู่ที่ไหน เช่น:
- makefile
- CopyEdit
C:\Program Files\Tesseract-OCR\tesseract.exe
ระบุ path ในโค้ด Python:
- python
- CopyEdit
import pytesseract pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
macOS (Homebrew):
brew install tesseract
Linux (Ubuntu):
sudo apt update
sudo apt install tesseract-ocr
✅ 2. ตรวจสอบว่า PATH ถูกต้อง (กรณีติดตั้งแล้ว)
หากติดตั้งแล้วแต่ยังเจอปัญหา อาจต้องเพิ่ม path ของ tesseract เข้าไปใน PATH ของระบบ
Windows (Command Prompt):
setx PATH "%PATH%;C:\Program Files\Tesseract-OCR"
หรือใช้ตัวแปรในโค้ดแบบนี้:
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r"C:\Your\Path\To\tesseract.exe"
✅ 3. ทดสอบการทำงาน
เมื่อทุกอย่างพร้อมแล้ว ทดสอบด้วยโค้ด:
from PIL import Image
import pytesseract
img = Image.open("sample_image.png")
text = pytesseract.image_to_string(img)
print(text)
หากคุณระบุระบบปฏิบัติการที่ใช้อยู่ (Windows, macOS, Linux) ผมสามารถแนะนำเฉพาะทางให้ได้ครับ.
สรุป
-
ให้ลง library pip install tesseract pip install tesseract-ocr
-
ให้ใส่ code บรรทัดนี้ในโค้ด แล้วใส่ path ให้ถูก (ใส่ไว้ใต้ import) pytesseract.pytesseract.tesseract_cmd = ‘C:\Program Files (x86)\Tesseract-OCR\tesseract.exe’
หมายเหตุท้าย: หากคุณชอบบทความนี้อย่าลืมคลิก❤ด้านล่างเพื่อแนะนำและถ้าคุณมีคำถามใด ๆ แสดงความคิดเห็นและฉันจะพยายามอย่างดีที่สุดที่จะตอบ คุณสามารถติดตามฉันบน facebook page (https://www.facebook.com/nextsoftwarehousethailand/) website : www.nextsoftwarethailand.com และสามารถส่งอีเมลถึงฉัน
메타데이터
- post_id
- b3cb371feff5
- slug
- error-pytesseract-pytesseract-tesseractnotfounderror-b3cb371feff5
- url
- https://medium.com/@dr-pathasu-doung/error-pytesseract-pytesseract-tesseractnotfounderror-b3cb371feff5
- canonical_url
- https://medium.com/@dr-pathasu-doung/error-pytesseract-pytesseract-tesseractnotfounderror-b3cb371feff5
- author_url
- https://medium.com/@dr-pathasu-doung
- status
- ok
- fetched_at
- 2026-07-20 01:21:36