• Register
1 vote
320 views

Problem:

I am besgginer in python programming language and I am following an oline course. For my coding practice I wrote this code:

from PIL import image

import pytesseract

ig = image.open(“course.jpg”) 

text = pytesseract.image_to_string(ig, lang=’eng’)

print(text)

But it does not compile and gives the following error message:

File "tes.py", line 7
    ig = image.open(“course.jpg”) 
                          ^
SyntaxError: invalid character in identifier

Can anyone srt out the problem?

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

1 vote

Answer:

If pytesseract is not installed in your virtual environment or your directories install it in your virtual environment or in your directorie by using the link:

 https://github.com/UB-Mannheim/tesseract/wiki

 or by running the command on your command prompt:

           

 pip install pytesseract

Make sure that the tesseract path from default installation time is: 

‘C:/Users/USER/AppData/Local/Tesseract-OCR’

, or it may change. So carefully check the installation path and note it.

Set the tesseract path in the script before calling image_to_string by running commang:

           

pytesseract.pytesseract.tesseract_cmd = r‘C:/Users/USER/AppData/Local/Tesseract-OCR/tesseract.exe’

I hope this may help you.

11 6 4
34,950 points

Related questions

0 votes
1 answer 244 views
244 views
Problem : Following is the script giving me the error I dont understand why it is giving me this The file starts with clear all filein=['Runs/']; Namein1=['AIC']; Nameout=['Nash']; It then does a lot of calculations and after that it tries to write the results to one ... I am not sure what is wrong here? What am I missing here? Please Note: I am running Matlab2013a on my MacBook Pro with OSX 10.8
asked Nov 21, 2019 peterlaw 6.9k points
0 votes
1 answer 1 view
1 view
Problem I am trying out this code but I keep running into a problem. What exactly is “invalid syntax” and why do I keep getting it in Python?
asked Apr 9 neeraj 10.5k points
0 votes
1 answer 56 views
56 views
def choose_option(self): if self.option_picker.currentRow() == 0: description = open(":/description_files/program_description.txt","r") self.information_shower.setText(description.read()) elif self.option_picker.currentRow() == 1: requirements = open(":/description_files/ ... it as argument in open function, but when i am using it for loading of pictures and icons everything is fine.
asked Oct 24, 2020 psandprop 2.4k points
1 vote
1 answer 65 views
65 views
Problem: In Python while practising the few question from c language i tried to implement the few of the program but most of the time it come up with the syntax error or the intend error can you help what actually i am missing the syntax error in python every time i execute it.
asked Jun 3, 2020 Gavin 15.3k points
0 votes
1 answer 192 views
192 views
Problem : Every time I submitted Python code, I got "invalid literal for int() with base 10:"
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
1 answer 3 views
3 views
Problem: How to remove all occurrences of a value from a list?
asked 3 days ago sumaiya simi 23.4k points
0 votes
1 answer 5 views
5 views
Problem: Hi there! Could someone please provide me the program that finds the specified character from a string in Python? The string and the character are to be taken as input from the user. The program should print found or not found based on the result of finding the character. Thank you!
asked Mar 31 Code Learner 9.5k points
1 vote
1 answer 2 views
2 views
Problem: How to fix this error : python count occurrences of character in string
asked Mar 30 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 3 views
3 views
Problem: I am stuck during learning as I have already mentioned in my question someone please cooperate me to continue my project-Thanks
asked Mar 29 tuhin1 48.9k points
0 votes
0 answers 4 views
4 views
Problem: I'm having problems during my learning as I mentioned in my question above, I try to find on web search but I can't get proper information, can you help me to continue my project?
asked Mar 29 tuhin1 48.9k points