OSError: [Errno 2] No such file or directory using pytesser

前端 未结 7 1999
鱼传尺愫
鱼传尺愫 2020-12-16 05:50

This is my problem, I want to use pytesser to get a picture\'s contents. My operating system is Mac OS 10.11, and I have already installed PIL, pytesser, tesseract-ocr engin

相关标签:
7条回答
  • 2020-12-16 05:59

    Luckily, I solved this one.

    At first, I run the command

    pip install pytesseract
    

    to install the package.

    But I get the error message of 'No such file or directory using pytesser'.

    Then I read this link: image_to_string doesn't work in Mac So, just run the following script:

    brew link libtiff 
    brew link libpng 
    brew link jpeg
    brew install tesseract
    

    Worked for me ~

    0 讨论(0)
  • 2020-12-16 05:59

    I had the same problem, but i managed to convert image to string. using apt-get should do the trick:

    sudo apt-get install tesseract-ocr
    

    and if you can't use it in a python script just do this:

    from os import system
    
    system("tesseract -l eng /image.png text.txt")
    
    0 讨论(0)
  • 2020-12-16 06:06

    I run into the same problem twice, for both MacOS and Ubuntu. This worked with me. Hoping it can help.

    First, open Terminal, then:

    • Ubuntu: run "sudo apt-get install tesseract-ocr"
    • MacOS: run "brew install tesseract". If you can not use "brew", run this command first then try again: "ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    0 讨论(0)
  • 2020-12-16 06:10

    You need to install tesseract-ocr:

    sudo apt-get install tesseract-ocr

    And in the script

        from PIL import Image
        import os
        import pytesseract
    
        text = pytesseract.image_to_string(Image.open(os.path.abspath('test.png')))
    
    0 讨论(0)
  • 2020-12-16 06:11

    Open file pytesseract.py.

    Mine is in /Users/yourUser/.virtualenvs/cv/lib/python2.7/site-packages/pytesseract/pytesseract.py

    Change tesseract_cmd = 'tesseract' to tesseract_cmd = '/usr/local/bin/tesseract'

    0 讨论(0)
  • 2020-12-16 06:11

    This might not be the case for everybody but I was having a similar issue and it was due to getting errors when installing tesseract. I kept getting the error message:

    Making install in ccutil
    /bin/sh: /Applications/Xcode: No such file or directory
    make: *** [install-recursive] Error 1
    

    This was due to me having previously renamed /Applications/Xcode to /Applications/Xcode 8 in order to make it easier for myself to distinguish between different Xcode versions installed on my system.

    I temporarily renamed it back to /Applications/Xcode then ran the command

    sudo xcode-select --switch /Applications/Xcode.app
    

    Then finally tried to reinstall tesseract and thankfully got no error messages this time.

    brew install tesseract --all-languages
    

    Now Python code runs fine and I get no "OSError: [Errno 2] No such file or directory" error message.

    0 讨论(0)
提交回复
热议问题